Don't crash when Database::DoesColumnExist is called on a poisoned DB
Many functions in sql::Database, in particular Database::DoesTableExist, handle a poisoned DB gracefully and return false in case the DB is poisoned. This CL adds similar logic to Database::DoesColumnExist. Bug: 1432475 Change-Id: Ib4ed90abb9dc4030ccac714b1dbd2388acb1a396 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4427823 Reviewed-by: Austin Sullivan <asully@chromium.org> Commit-Queue: Dominic Battre <battre@chromium.org> Cr-Commit-Position: refs/heads/main@{#1144202}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f3302a1cfe
commit
f6ec7421c6
@ -1675,6 +1675,11 @@ bool Database::DoesColumnExist(const char* table_name,
|
||||
const char* column_name) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
if (!db_) {
|
||||
DCHECK(poisoned_) << "Illegal use of Database without a db";
|
||||
return false;
|
||||
}
|
||||
|
||||
// sqlite3_table_column_metadata uses out-params to return column definition
|
||||
// details, such as the column type and whether it allows NULL values. These
|
||||
// aren't needed to compute the current method's result, so we pass in nullptr
|
||||
|
Reference in New Issue
Block a user