1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-04 04:42:17 +03:00

Fix an off-by-one boundary-value issue in walCleanupHash().

FossilOrigin-Name: f039552e6330b6a04281748f985b41937f534bd0
This commit is contained in:
drh
2010-06-01 12:58:41 +00:00
parent 72bcac9ca7
commit 9c1564779e
3 changed files with 26 additions and 11 deletions

View File

@@ -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;