diff options
author | drh <drh@noemail.net> | 2020-05-26 10:54:46 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-05-26 10:54:46 +0000 |
commit | bdd4f7d91c7ee622c914d96f8f36e6b6d523f9df (patch) | |
tree | 019dd61614f0e2e7f18c047ed5bd13cdde56c626 /src | |
parent | d63c76fb31a0e262fb12a93b171e95a4e30c1a2e (diff) | |
download | sqlite-bdd4f7d91c7ee622c914d96f8f36e6b6d523f9df.tar.gz sqlite-bdd4f7d91c7ee622c914d96f8f36e6b6d523f9df.zip |
Innocuous changes to help Coverity avoid false-positives.
FossilOrigin-Name: 4ec8a5a203f10d228d0b3389120638766cc343179dbe38d5dbf69b650765934c
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 1 | ||||
-rw-r--r-- | src/prepare.c | 11 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/expr.c b/src/expr.c index c5b678387..69cd674ef 100644 --- a/src/expr.c +++ b/src/expr.c @@ -2563,6 +2563,7 @@ int sqlite3FindInIndex( /* Code an OP_Transaction and OP_TableLock for <table>. */ iDb = sqlite3SchemaToIndex(db, pTab->pSchema); + assert( iDb>=0 && iDb<SQLITE_MAX_ATTACHED ); sqlite3CodeVerifySchema(pParse, iDb); sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); diff --git a/src/prepare.c b/src/prepare.c index 228d14876..259954676 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -504,17 +504,18 @@ static void schemaIsValid(Parse *pParse){ ** attached database is returned. */ int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){ - int i = -1000000; + int i = -32768; - /* If pSchema is NULL, then return -1000000. This happens when code in + /* If pSchema is NULL, then return -32768. This happens when code in ** expr.c is trying to resolve a reference to a transient table (i.e. one ** created by a sub-select). In this case the return value of this ** function should never be used. ** - ** We return -1000000 instead of the more usual -1 simply because using - ** -1000000 as the incorrect index into db->aDb[] is much + ** We return -32768 instead of the more usual -1 simply because using + ** -32768 as the incorrect index into db->aDb[] is much ** more likely to cause a segfault than -1 (of course there are assert() - ** statements too, but it never hurts to play the odds). + ** statements too, but it never hurts to play the odds) and + ** -32768 will still fit into a 16-bit signed integer. */ assert( sqlite3_mutex_held(db->mutex) ); if( pSchema ){ |