aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2008-05-05 12:09:32 +0000
committerdanielk1977 <danielk1977@noemail.net>2008-05-05 12:09:32 +0000
commit43e377af3ff53d7f43c48b81b0ddedda55001e53 (patch)
treeab4368c4bbcea7462c0c4c58d2677c16de31957b /src
parent286d2f4a92841cc4d2d2a631a4a77630e061e750 (diff)
downloadsqlite-43e377af3ff53d7f43c48b81b0ddedda55001e53.tar.gz
sqlite-43e377af3ff53d7f43c48b81b0ddedda55001e53.zip
Avoid leaking page references when database corruption is encountered. (CVS 5080)
FossilOrigin-Name: 270d47e8d0a20868879a95b66cb547e1e5b642d9
Diffstat (limited to 'src')
-rw-r--r--src/btree.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/btree.c b/src/btree.c
index 4337fc2ef..7897b7470 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -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",