1
0
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:
drh
2019-02-09 22:33:44 +00:00
parent b0ea9432a1
commit 85a379b74b
3 changed files with 14 additions and 13 deletions

View File

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