mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
On unix, for certain error codes of read()/pread() return
SQLITE_IOERR_CORRUPTFS instead of SQLITE_IOERR_READ. And then convert this error into SQLITE_CORRUPT prior to returning back to the application. FossilOrigin-Name: 9538ea8447e7b07c05197d6ff2208d3e97b45798736c85b63e8f0c7a3a98c1f3
This commit is contained in:
20
src/malloc.c
20
src/malloc.c
@@ -791,12 +791,18 @@ 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;
|
||||
}
|
||||
if( rc==SQLITE_IOERR_CORRUPTFS ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
return rc & db->errMask;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -818,8 +824,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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user