aboutsummaryrefslogtreecommitdiff
path: root/src/wal.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2019-04-03 17:48:10 +0000
committerdrh <drh@noemail.net>2019-04-03 17:48:10 +0000
commitb92d7d264ea0b811267a91b0ece3e7170bd57d6a (patch)
treee18a0ac28b1ebc9384f3381519ad1f7e237e3587 /src/wal.c
parent3f49c321e81905648abdb55f7fdf17dc06750a90 (diff)
downloadsqlite-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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wal.c b/src/wal.c
index 4088bf2ec..bf1188da4 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -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.