diff options
author | drh <drh@noemail.net> | 2019-04-03 17:48:10 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-04-03 17:48:10 +0000 |
commit | b92d7d264ea0b811267a91b0ece3e7170bd57d6a (patch) | |
tree | e18a0ac28b1ebc9384f3381519ad1f7e237e3587 /src/wal.c | |
parent | 3f49c321e81905648abdb55f7fdf17dc06750a90 (diff) | |
download | sqlite-b92d7d264ea0b811267a91b0ece3e7170bd57d6a.tar.gz sqlite-b92d7d264ea0b811267a91b0ece3e7170bd57d6a.zip |
Add a defense-in-depth NEVER() test to the WAL cleanup code.
FossilOrigin-Name: 8d3af2010f4f652865f5c0d18e3bc793de05f8e75e75cc77786f61004b2ad28f
Diffstat (limited to 'src/wal.c')
-rw-r--r-- | src/wal.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -986,6 +986,7 @@ static void walCleanupHash(Wal *pWal){ int iLimit = 0; /* Zero values greater than this */ int nByte; /* Number of bytes to zero in aPgno[] */ int i; /* Used to iterate through aHash[] */ + int rc; /* Return code form walHashGet() */ assert( pWal->writeLock ); testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE_ONE-1 ); @@ -996,11 +997,12 @@ static void walCleanupHash(Wal *pWal){ /* Obtain pointers to the hash-table and page-number array containing ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed - ** that the page said hash-table and array reside on is already mapped. + ** that the page said hash-table and array reside on is already mapped.(1) */ assert( pWal->nWiData>walFramePage(pWal->hdr.mxFrame) ); assert( pWal->apWiData[walFramePage(pWal->hdr.mxFrame)] ); - walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); + rc = walHashGet(pWal, walFramePage(pWal->hdr.mxFrame), &sLoc); + if( NEVER(rc) ) return; /* Defense-in-depth, in case (1) above is wrong */ /* Zero all hash-table entries that correspond to frame numbers greater ** than pWal->hdr.mxFrame. |