Index: src/test1.c ================================================================== --- src/test1.c +++ src/test1.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.140 2005/05/27 09:41:13 danielk1977 Exp $ +** $Id: test1.c,v 1.141 2005/06/06 17:54:56 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include @@ -61,11 +61,11 @@ /* ** Convert an sqlite3_stmt* into an sqlite3*. This depends on the ** fact that the sqlite3* is the first field in the Vdbe structure. */ -#define StmtToDb(X) (*(sqlite3**)(X)) +#define StmtToDb(X) ((X)?*(sqlite3**)(X):0) /* ** Check a return value to make sure it agrees with the results ** from sqlite3_errcode. */ @@ -1603,10 +1603,11 @@ if( Tcl_GetIntFromObj(interp, objv[4], &bytes) ) return TCL_ERROR; rc = sqlite3_bind_text(pStmt, idx, value, bytes, SQLITE_TRANSIENT); if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, sqlite3TestErrorName(rc), 0); return TCL_ERROR; } return TCL_OK; } Index: src/vdbeapi.c ================================================================== --- src/vdbeapi.c +++ src/vdbeapi.c @@ -499,11 +499,11 @@ ** value in any case. */ static int vdbeUnbind(Vdbe *p, int i){ Mem *pVar; if( p==0 || p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){ - sqlite3Error(p->db, SQLITE_MISUSE, 0); + if( p ) sqlite3Error(p->db, SQLITE_MISUSE, 0); return SQLITE_MISUSE; } if( i<1 || i>p->nVar ){ sqlite3Error(p->db, SQLITE_RANGE, 0); return SQLITE_RANGE; Index: test/capi3.test ================================================================== --- test/capi3.test +++ test/capi3.test @@ -9,11 +9,11 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the callback-free C/C++ API. # -# $Id: capi3.test,v 1.32 2005/05/26 16:23:34 drh Exp $ +# $Id: capi3.test,v 1.33 2005/06/06 17:54:56 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -850,7 +850,15 @@ do_test capi3-13-5 { set ms [sqlite3_sleep 80] expr {$ms==80 || $ms==1000} } {1} } + +# Ticket #1219: Make sure binding APIs can handle a NULL pointer. +# +do_test capi3-14.1 { + set rc [catch {sqlite3_bind_text 0 1 hello 5} msg] + lappend rc $msg +} {1 SQLITE_MISUSE} + finish_test