mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
When computing the amount of scratch memory needed during a rebalance operation,
assume the worst case for the number of cells per page, rather than relying on the BtPage.nCell value, which might be incorrect for a corrupt database. FossilOrigin-Name: a420ebd08f5a96b9e61a37cb42e1b3f346c23505630d9c33fe30ce7882959b36
This commit is contained in:
@@ -7559,7 +7559,6 @@ static int balance_nonroot(
|
||||
goto balance_cleanup;
|
||||
}
|
||||
}
|
||||
nMaxCells += 1+apOld[i]->nCell+apOld[i]->nOverflow;
|
||||
if( (i--)==0 ) break;
|
||||
|
||||
if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
|
||||
@@ -7603,6 +7602,7 @@ static int balance_nonroot(
|
||||
|
||||
/* Make nMaxCells a multiple of 4 in order to preserve 8-byte
|
||||
** alignment */
|
||||
nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
|
||||
nMaxCells = (nMaxCells + 3)&~3;
|
||||
|
||||
/*
|
||||
@@ -7613,7 +7613,7 @@ static int balance_nonroot(
|
||||
+ nMaxCells*sizeof(u16) /* b.szCell */
|
||||
+ pBt->pageSize; /* aSpace1 */
|
||||
|
||||
assert( szScratch<=6*(int)pBt->pageSize );
|
||||
assert( szScratch<=7*(int)pBt->pageSize );
|
||||
b.apCell = sqlite3StackAllocRaw(0, szScratch );
|
||||
if( b.apCell==0 ){
|
||||
rc = SQLITE_NOMEM_BKPT;
|
||||
|
Reference in New Issue
Block a user