mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Fix a page-cache reference leak in the btree balancer when there is a corrupt
database. FossilOrigin-Name: 9285899120dec24ff2944431ad455d7ae217ef408ae2f1a3e7bdfb897099028c
This commit is contained in:
10
src/btree.c
10
src/btree.c
@@ -7550,13 +7550,17 @@ static int balance_nonroot(
|
||||
pgno = get4byte(pRight);
|
||||
while( 1 ){
|
||||
rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0);
|
||||
if( rc==0 && apOld[i]->nFree<0 ){
|
||||
rc = btreeComputeFreeSpace(apOld[i]);
|
||||
}
|
||||
if( rc ){
|
||||
memset(apOld, 0, (i+1)*sizeof(MemPage*));
|
||||
goto balance_cleanup;
|
||||
}
|
||||
if( apOld[i]->nFree<0 ){
|
||||
rc = btreeComputeFreeSpace(apOld[i]);
|
||||
if( rc ){
|
||||
memset(apOld, 0, (i)*sizeof(MemPage*));
|
||||
goto balance_cleanup;
|
||||
}
|
||||
}
|
||||
nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
|
||||
if( (i--)==0 ) break;
|
||||
|
||||
|
Reference in New Issue
Block a user