diff options
author | dan <Dan Kennedy> | 2021-03-01 16:16:59 +0000 |
---|---|---|
committer | dan <Dan Kennedy> | 2021-03-01 16:16:59 +0000 |
commit | 531d01cae013213d1cf4ba2a41ed3cfa870d295e (patch) | |
tree | f4de563557b885525da0b755355b253b9a428efc /src | |
parent | a3944bc4fe7cb12d542a3bf4b70799161961889b (diff) | |
parent | 1f9f5766954d250a00da59f7f7c1fc57d9032a6e (diff) | |
download | sqlite-531d01cae013213d1cf4ba2a41ed3cfa870d295e.tar.gz sqlite-531d01cae013213d1cf4ba2a41ed3cfa870d295e.zip |
Fix a couple of memory-sanitizer complaints that could be triggered by a corrupt database.
FossilOrigin-Name: 39c8686cabe6c437ba4860aade49a701c4f5772b97d9fbe6cb9a394e85b9c092
Diffstat (limited to 'src')
-rw-r--r-- | src/btree.c | 12 | ||||
-rw-r--r-- | src/pcache1.c | 1 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/btree.c b/src/btree.c index d0e51b82d..709445b16 100644 --- a/src/btree.c +++ b/src/btree.c @@ -7637,7 +7637,9 @@ static int balance_nonroot( } pgno = get4byte(pRight); while( 1 ){ - rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0); + if( rc==SQLITE_OK ){ + rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0); + } if( rc ){ memset(apOld, 0, (i+1)*sizeof(MemPage*)); goto balance_cleanup; @@ -7676,12 +7678,10 @@ static int balance_nonroot( if( pBt->btsFlags & BTS_FAST_SECURE ){ int iOff; + /* If the following if() condition is not true, the db is corrupted. + ** The call to dropCell() below will detect this. */ iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData); - if( (iOff+szNew[i])>(int)pBt->usableSize ){ - rc = SQLITE_CORRUPT_BKPT; - memset(apOld, 0, (i+1)*sizeof(MemPage*)); - goto balance_cleanup; - }else{ + if( (iOff+szNew[i])<=(int)pBt->usableSize ){ memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData]; } diff --git a/src/pcache1.c b/src/pcache1.c index ed762ebf7..3eae6b63c 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -461,6 +461,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ p->page.pExtra = &p[1]; p->isBulkLocal = 0; p->isAnchor = 0; + p->pLruPrev = 0; /* Initializing this saves a valgrind error */ } (*pCache->pnPurgeable)++; return p; |