Change sqlite_blob_open() so that it zeros the output pBlob pointer when

it fails.  The other sqlite3_blob interfaces accept a NULL pointer as
input. (CVS 6622)

FossilOrigin-Name: 999d507b4432b518cfc7e02e5b0a2473cf1980f6
This commit is contained in:
drh 2009-05-09 15:17:47 +00:00
parent 9ab4c2e880
commit 28414ee952
3 changed files with 28 additions and 20 deletions

View File

@ -1,5 +1,5 @@
C Changes\sto\sthe\strigger.c\smodule\sthat\sfacilitate\sfull\scoverage\stesting.\s(CVS\s6621)
D 2009-05-09T00:18:38
C Change\ssqlite_blob_open()\sso\sthat\sit\szeros\sthe\soutput\spBlob\spointer\swhen\nit\sfails.\s\sThe\sother\ssqlite3_blob\sinterfaces\saccept\sa\sNULL\spointer\sas\ninput.\s(CVS\s6622)
D 2009-05-09T15:17:47
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 583e87706abc3026960ed759aff6371faf84c211
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -208,7 +208,7 @@ F src/vdbe.h 35a648bc3279a120da24f34d9a25213ec15daf8a
F src/vdbeInt.h 43183a2a18654fa570219ab65e53a608057c48ae
F src/vdbeapi.c 86aa27a5f3493aaffb8ac051782aa3b22670d7ed
F src/vdbeaux.c 1a07329bdf51cc3687f88d9f5b2bd3f1d47cc5a8
F src/vdbeblob.c e67757450ae8581a8b354d9d7e467e41502dfe38
F src/vdbeblob.c 5c5abe9af28316772e7829359f6f9cda2c737ebd
F src/vdbemem.c d8b985eeb88214941380372466a30ca410043a93
F src/vtab.c 53355aa2381ec3ef2eaad25672cfd5877a02fe45
F src/walker.c 7cdf63223c953d4343c6833e940f110281a378ee
@ -729,7 +729,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 254ca3273cfbd833de82296b4859e1ec5535e8be
R 29c312f4710fcc89e520e552563a8498
P 567ccc68cc8c73b952a91c71a0e00b08bb25c689
R 886144e41731ebf2955c0b2ed8aed044
U drh
Z 4d4c05b89d8d2f3c2da064b74794e76b
Z fabb4ba3bc1d6719d08d21dcbbdf7cee

View File

@ -1 +1 @@
567ccc68cc8c73b952a91c71a0e00b08bb25c689
999d507b4432b518cfc7e02e5b0a2473cf1980f6

View File

@ -12,7 +12,7 @@
**
** This file contains code used to implement incremental BLOB I/O.
**
** $Id: vdbeblob.c,v 1.31 2009/03/24 15:08:10 drh Exp $
** $Id: vdbeblob.c,v 1.32 2009/05/09 15:17:47 drh Exp $
*/
#include "sqliteInt.h"
@ -85,6 +85,7 @@ int sqlite3_blob_open(
int rc = SQLITE_OK;
char zErr[128];
*ppBlob = 0;
zErr[0] = 0;
sqlite3_mutex_enter(db->mutex);
do {
@ -176,9 +177,10 @@ int sqlite3_blob_open(
/* Remove either the OP_OpenWrite or OpenRead. Set the P2
** parameter of the other to pTab->tnum.
*/
sqlite3VdbeChangeToNoop(v, (flags ? 2 : 3), 1);
sqlite3VdbeChangeP2(v, (flags ? 3 : 2), pTab->tnum);
sqlite3VdbeChangeP3(v, (flags ? 3 : 2), iDb);
flags = !!flags;
sqlite3VdbeChangeToNoop(v, 3 - flags, 1);
sqlite3VdbeChangeP2(v, 2 + flags, pTab->tnum);
sqlite3VdbeChangeP3(v, 2 + flags, iDb);
/* Configure the number of columns. Configure the cursor to
** think that the table has one more column than it really
@ -187,7 +189,7 @@ int sqlite3_blob_open(
** we can invoke OP_Column to fill in the vdbe cursors type
** and offset cache without causing any IO.
*/
sqlite3VdbeChangeP4(v, flags ? 3 : 2, SQLITE_INT_TO_PTR(pTab->nCol+1), P4_INT32);
sqlite3VdbeChangeP4(v, 2+flags, SQLITE_INT_TO_PTR(pTab->nCol+1),P4_INT32);
sqlite3VdbeChangeP2(v, 6, pTab->nCol);
if( !db->mallocFailed ){
sqlite3VdbeMakeReady(v, 1, 1, 1, 0);
@ -196,7 +198,7 @@ int sqlite3_blob_open(
sqlite3BtreeLeaveAll(db);
rc = sqlite3SafetyOff(db);
if( rc!=SQLITE_OK || db->mallocFailed ){
if( NEVER(rc!=SQLITE_OK) || db->mallocFailed ){
goto blob_open_out;
}
@ -266,11 +268,15 @@ int sqlite3_blob_close(sqlite3_blob *pBlob){
int rc;
sqlite3 *db;
db = p->db;
sqlite3_mutex_enter(db->mutex);
rc = sqlite3_finalize(p->pStmt);
sqlite3DbFree(db, p);
sqlite3_mutex_leave(db->mutex);
if( p ){
db = p->db;
sqlite3_mutex_enter(db->mutex);
rc = sqlite3_finalize(p->pStmt);
sqlite3DbFree(db, p);
sqlite3_mutex_leave(db->mutex);
}else{
rc = SQLITE_OK;
}
return rc;
}
@ -287,8 +293,10 @@ static int blobReadWrite(
int rc;
Incrblob *p = (Incrblob *)pBlob;
Vdbe *v;
sqlite3 *db = p->db;
sqlite3 *db;
if( p==0 ) return SQLITE_MISUSE;
db = p->db;
sqlite3_mutex_enter(db->mutex);
v = (Vdbe*)p->pStmt;
@ -344,7 +352,7 @@ int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
*/
int sqlite3_blob_bytes(sqlite3_blob *pBlob){
Incrblob *p = (Incrblob *)pBlob;
return p->nByte;
return p ? p->nByte : 0;
}
#endif /* #ifndef SQLITE_OMIT_INCRBLOB */