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

Fix an obscure pager refcnt leak that occurs following a transient I/O

error. (CVS 3829)

FossilOrigin-Name: ce6f56ece8eab743d20cd2c0a84b4a266c4da2ff
This commit is contained in:
drh
2007-04-09 12:45:02 +00:00
parent 9038bb647f
commit f53454438a
5 changed files with 27 additions and 26 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.353 2007/04/07 15:03:17 danielk1977 Exp $
** $Id: btree.c,v 1.354 2007/04/09 12:45:03 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -3944,12 +3944,13 @@ static int freePage(MemPage *pPage){
}else{
/* Add the newly freed page as a leaf on the current trunk */
rc = sqlite3PagerWrite(pTrunk->pDbPage);
if( rc ) return rc;
put4byte(&pTrunk->aData[4], k+1);
put4byte(&pTrunk->aData[8+k*4], pPage->pgno);
if( rc==SQLITE_OK ){
put4byte(&pTrunk->aData[4], k+1);
put4byte(&pTrunk->aData[8+k*4], pPage->pgno);
#ifndef SQLITE_SECURE_DELETE
sqlite3PagerDontWrite(pBt->pPager, pPage->pgno);
sqlite3PagerDontWrite(pBt->pPager, pPage->pgno);
#endif
}
TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));
}
releasePage(pTrunk);
@@ -4835,14 +4836,15 @@ static int balance_nonroot(MemPage *pPage){
pgnoNew[i] = pgnoOld[i];
apOld[i] = 0;
rc = sqlite3PagerWrite(pNew->pDbPage);
nNew++;
if( rc ) goto balance_cleanup;
}else{
assert( i>0 );
rc = allocateBtreePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0);
if( rc ) goto balance_cleanup;
apNew[i] = pNew;
nNew++;
}
nNew++;
zeroPage(pNew, pageFlags);
}
@@ -5419,11 +5421,6 @@ int sqlite3BtreeDelete(BtCursor *pCur){
assert( !pPage->leafData );
getTempCursor(pCur, &leafCur);
rc = sqlite3BtreeNext(&leafCur, &notUsed);
if( rc!=SQLITE_OK ){
if( rc!=SQLITE_NOMEM ){
rc = SQLITE_CORRUPT_BKPT;
}
}
if( rc==SQLITE_OK ){
rc = sqlite3PagerWrite(leafCur.pPage->pDbPage);
}