mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Prevent an infinite loop while searching a corrupt freelist.
FossilOrigin-Name: 4e5424fe89eed346f6cf26a05c72694d1eb9f58f
This commit is contained in:
@@ -5423,6 +5423,7 @@ static int allocateBtreePage(
|
||||
/* There are pages on the freelist. Reuse one of those pages. */
|
||||
Pgno iTrunk;
|
||||
u8 searchList = 0; /* If the free-list must be searched for 'nearby' */
|
||||
int nSearch = 0; /* Count of the number of search attempts */
|
||||
|
||||
/* If eMode==BTALLOC_EXACT and a query of the pointer-map
|
||||
** shows that the page 'nearby' is somewhere on the free-list, then
|
||||
@@ -5471,7 +5472,7 @@ static int allocateBtreePage(
|
||||
iTrunk = get4byte(&pPage1->aData[32]);
|
||||
}
|
||||
testcase( iTrunk==mxPage );
|
||||
if( iTrunk>mxPage ){
|
||||
if( iTrunk>mxPage || nSearch++ > n ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
}else{
|
||||
rc = btreeGetUnusedPage(pBt, iTrunk, &pTrunk, 0);
|
||||
|
Reference in New Issue
Block a user