diff options
author | drh <drh@noemail.net> | 2010-06-01 12:58:41 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-06-01 12:58:41 +0000 |
commit | 9c1564779e367e501e425342eee6eb57a1804d4c (patch) | |
tree | 7159d8eff2bd612f551370d60877610c5b7e364c /src | |
parent | 72bcac9ca70d580ed5f02e7d08e3a23bb24e9194 (diff) | |
download | sqlite-9c1564779e367e501e425342eee6eb57a1804d4c.tar.gz sqlite-9c1564779e367e501e425342eee6eb57a1804d4c.zip |
Fix an off-by-one boundary-value issue in walCleanupHash().
FossilOrigin-Name: f039552e6330b6a04281748f985b41937f534bd0
Diffstat (limited to 'src')
-rw-r--r-- | src/wal.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -822,11 +822,16 @@ static void walCleanupHash(Wal *pWal){ int iLimit; /* Zero values greater than this */ assert( pWal->writeLock ); - walHashFind(pWal, pWal->hdr.mxFrame+1, &aHash, &aPgno, &iZero); - iLimit = pWal->hdr.mxFrame - iZero; - if( iLimit>0 ){ + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE-1 ); + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE ); + testcase( pWal->hdr.mxFrame==HASHTABLE_NPAGE+1 ); + if( (pWal->hdr.mxFrame % HASHTABLE_NPAGE)>0 ){ int nByte; /* Number of bytes to zero in aPgno[] */ int i; /* Used to iterate through aHash[] */ + + walHashFind(pWal, pWal->hdr.mxFrame+1, &aHash, &aPgno, &iZero); + iLimit = pWal->hdr.mxFrame - iZero; + assert( iLimit>0 ); for(i=0; i<HASHTABLE_NSLOT; i++){ if( aHash[i]>iLimit ){ aHash[i] = 0; |