mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Simplifications to btree.c to help facilitate coverage testing. (CVS 6884)
FossilOrigin-Name: dfb146ef003bae8ff216baf68cc43d7eb7855c68
This commit is contained in:
14
src/btree.c
14
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.681 2009/07/11 18:26:29 drh Exp $
|
||||
** $Id: btree.c,v 1.682 2009/07/12 02:32:22 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@@ -3606,10 +3606,8 @@ static int copyPayload(
|
||||
** A total of "amt" bytes are read or written beginning at "offset".
|
||||
** Data is read to or from the buffer pBuf.
|
||||
**
|
||||
** This routine does not make a distinction between key and data.
|
||||
** It just reads or writes bytes from the payload area. Data might
|
||||
** appear on the main page or be scattered out on multiple overflow
|
||||
** pages.
|
||||
** The content being read or written might appear on the main page
|
||||
** or be scattered out on multiple overflow pages.
|
||||
**
|
||||
** If the BtCursor.isIncrblobHandle flag is set, and the current
|
||||
** cursor entry uses one or more overflow pages, this function
|
||||
@@ -3649,7 +3647,7 @@ static int accessPayload(
|
||||
aPayload = pCur->info.pCell + pCur->info.nHeader;
|
||||
nKey = (pPage->intKey ? 0 : (int)pCur->info.nKey);
|
||||
|
||||
if( offset+amt > nKey+pCur->info.nData
|
||||
if( NEVER(offset+amt > nKey+pCur->info.nData)
|
||||
|| &aPayload[pCur->info.nLocal] > &pPage->aData[pBt->usableSize]
|
||||
){
|
||||
/* Trying to read or write past the end of the data is an error */
|
||||
@@ -3687,7 +3685,9 @@ static int accessPayload(
|
||||
if( pCur->isIncrblobHandle && !pCur->aOverflow ){
|
||||
int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
|
||||
pCur->aOverflow = (Pgno *)sqlite3MallocZero(sizeof(Pgno)*nOvfl);
|
||||
if( nOvfl && !pCur->aOverflow ){
|
||||
/* nOvfl is always positive. If it were zero, fetchPayload would have
|
||||
** been used instead of this routine. */
|
||||
if( ALWAYS(nOvfl) && !pCur->aOverflow ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user