diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/test1.c | 16 | ||||
-rw-r--r-- | src/vdbeblob.c | 20 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/test1.c b/src/test1.c index 722c09e75..c54173e8d 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.325 2008/09/11 10:29:16 danielk1977 Exp $ +** $Id: test1.c,v 1.326 2008/10/02 14:49:02 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -1559,7 +1559,7 @@ static int test_blob_read( } /* -** sqlite3_blob_write CHANNEL OFFSET DATA +** sqlite3_blob_write CHANNEL OFFSET DATA ?NDATA? ** ** This command is used to test the sqlite3_blob_write() in ways that ** the Tcl channel interface does not. The first argument should @@ -1588,16 +1588,13 @@ static int test_blob_write( unsigned char *zBuf; int nBuf; - if( objc!=4 ){ - Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL OFFSET DATA"); + if( objc!=4 && objc!=5 ){ + Tcl_WrongNumArgs(interp, 1, objv, "CHANNEL OFFSET DATA ?NDATA?"); return TCL_ERROR; } channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), ¬Used); - if( !channel - || TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) - || iOffset<0 - ){ + if( !channel || TCL_OK!=Tcl_GetIntFromObj(interp, objv[2], &iOffset) ){ return TCL_ERROR; } @@ -1605,6 +1602,9 @@ static int test_blob_write( pBlob = *((sqlite3_blob **)instanceData); zBuf = Tcl_GetByteArrayFromObj(objv[3], &nBuf); + if( objc==5 && Tcl_GetIntFromObj(interp, objv[4], &nBuf) ){ + return TCL_ERROR; + } rc = sqlite3_blob_write(pBlob, zBuf, nBuf, iOffset); if( rc!=SQLITE_OK ){ Tcl_SetResult(interp, (char *)sqlite3TestErrorName(rc), TCL_VOLATILE); diff --git a/src/vdbeblob.c b/src/vdbeblob.c index 746bfe4c3..9afeb11c0 100644 --- a/src/vdbeblob.c +++ b/src/vdbeblob.c @@ -12,7 +12,7 @@ ** ** This file contains code used to implement incremental BLOB I/O. ** -** $Id: vdbeblob.c,v 1.25 2008/07/28 19:34:54 drh Exp $ +** $Id: vdbeblob.c,v 1.26 2008/10/02 14:49:02 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -287,17 +287,17 @@ static int blobReadWrite( Vdbe *v; sqlite3 *db = p->db; - /* Request is out of range. Return a transient error. */ - if( (iOffset+n)>p->nByte ){ - return SQLITE_ERROR; - } sqlite3_mutex_enter(db->mutex); - - /* If there is no statement handle, then the blob-handle has - ** already been invalidated. Return SQLITE_ABORT in this case. - */ v = (Vdbe*)p->pStmt; - if( v==0 ){ + + if( n<0 || iOffset<0 || (iOffset+n)>p->nByte ){ + /* Request is out of range. Return a transient error. */ + rc = SQLITE_ERROR; + sqlite3Error(db, SQLITE_ERROR, 0); + } else if( v==0 ){ + /* If there is no statement handle, then the blob-handle has + ** already been invalidated. Return SQLITE_ABORT in this case. + */ rc = SQLITE_ABORT; }else{ /* Call either BtreeData() or BtreePutData(). If SQLITE_ABORT is |