diff options
author | drh <drh@noemail.net> | 2020-11-18 23:44:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-11-18 23:44:41 +0000 |
commit | 02e4b7d7df1e8a66529d508d4cfcfbbca39953d2 (patch) | |
tree | 624254dcc490598977e23bf4546383e9f1a78438 /src/malloc.c | |
parent | 8ea11095c9c98444b37430f2c39fc4a6d77a3c4e (diff) | |
parent | f56a4bfcd12cb7990ef171ffb89d2a27cd03ed4e (diff) | |
download | sqlite-02e4b7d7df1e8a66529d508d4cfcfbbca39953d2.tar.gz sqlite-02e4b7d7df1e8a66529d508d4cfcfbbca39953d2.zip |
If a read() or pread() indicates that the database file is unreadable due to
filesystem damage, then it returns SQLITE_IOERR_CORRUPTFS which is then
converted into SQLITE_CORRUPT before being returned to the application.
FossilOrigin-Name: 849e4e14fd06eda512381f5f8aa65f75ad0a955e835da7c63526a53cf5e8f4dc
Diffstat (limited to 'src/malloc.c')
-rw-r--r-- | src/malloc.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/malloc.c b/src/malloc.c index 35ad21ecc..a0f7a739c 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -791,12 +791,15 @@ void sqlite3OomClear(sqlite3 *db){ } /* -** Take actions at the end of an API call to indicate an OOM error +** Take actions at the end of an API call to deal with error codes. */ -static SQLITE_NOINLINE int apiOomError(sqlite3 *db){ - sqlite3OomClear(db); - sqlite3Error(db, SQLITE_NOMEM); - return SQLITE_NOMEM_BKPT; +static SQLITE_NOINLINE int apiHandleError(sqlite3 *db, int rc){ + if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){ + sqlite3OomClear(db); + sqlite3Error(db, SQLITE_NOMEM); + return SQLITE_NOMEM_BKPT; + } + return rc & db->errMask; } /* @@ -818,8 +821,8 @@ int sqlite3ApiExit(sqlite3* db, int rc){ */ assert( db!=0 ); assert( sqlite3_mutex_held(db->mutex) ); - if( db->mallocFailed || rc==SQLITE_IOERR_NOMEM ){ - return apiOomError(db); + if( db->mallocFailed || rc ){ + return apiHandleError(db, rc); } return rc & db->errMask; } |