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

Avoid leaking page references when database corruption is encountered. (CVS 5080)

FossilOrigin-Name: 270d47e8d0a20868879a95b66cb547e1e5b642d9
This commit is contained in:
danielk1977
2008-05-05 12:09:32 +00:00
parent 286d2f4a92
commit 43e377af3f
4 changed files with 25 additions and 11 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.453 2008/05/02 14:23:55 drh Exp $
** $Id: btree.c,v 1.454 2008/05/05 12:09:33 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
@@ -1054,6 +1054,10 @@ static int getAndInitPage(
rc = sqlite3BtreeGetPage(pBt, pgno, ppPage, 0);
if( rc==SQLITE_OK && (*ppPage)->isInit==0 ){
rc = sqlite3BtreeInitPage(*ppPage, pParent);
if( rc!=SQLITE_OK ){
releasePage(*ppPage);
*ppPage = 0;
}
}
return rc;
}
@@ -4091,7 +4095,8 @@ static int allocateBtreePage(
*pPgno = iPage;
if( *pPgno>sqlite3PagerPagecount(pBt->pPager) ){
/* Free page off the end of the file */
return SQLITE_CORRUPT_BKPT;
rc = SQLITE_CORRUPT_BKPT;
goto end_allocate_page;
}
TRACE(("ALLOCATE: %d was leaf %d of %d on trunk %d"
": %d more free pages\n",