]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Return SQLITE_MISUSE instead of crashing if NULL is (incorrectly) passed to sqlite3_s...
authordanielk1977 <danielk1977@noemail.net>
Thu, 15 Nov 2007 16:04:15 +0000 (16:04 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Thu, 15 Nov 2007 16:04:15 +0000 (16:04 +0000)
FossilOrigin-Name: 3bfee76fa6191c6e3aaa4632949b53253c612f36

manifest
manifest.uuid
src/vdbeapi.c

index be2daf153680224c75e2eabd20320e7149d0d5c7..1745e058bef20ba89e1189d1ce88fe35fe94a7ac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\ssegfault\sthat\scan\soccur\safter\sa\smalloc\sfailure\sin\san\sANALYZE\sstatement.\sTicket\s#2772.\s(CVS\s4544)
-D 2007-11-15T13:10:23
+C Return\sSQLITE_MISUSE\sinstead\sof\scrashing\sif\sNULL\sis\s(incorrectly)\spassed\sto\ssqlite3_step().\sTicket\s#2773.\s(CVS\s4545)
+D 2007-11-15T16:04:15
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -169,7 +169,7 @@ F src/vacuum.c a5e51c77370c1a6445e86d42abfc43867cdd482d
 F src/vdbe.c 791d056da2c264c2cfed6e2150852926845875e5
 F src/vdbe.h 79e09ff13b85457abe437d9814454534ebbc1fe3
 F src/vdbeInt.h 630145b9bfaa19190ab491f52658a7db550f2247
-F src/vdbeapi.c eecea7fa87e20664acf270f17c6f397421e9344b
+F src/vdbeapi.c dd2c43317294e0a013e9f634ee4209a3ea459b43
 F src/vdbeaux.c ffc2610c0d29a6e7b5c1d5dfea2ad406f7f9aff1
 F src/vdbeblob.c 82f51cdf9b0c0af729732fde48c824e498c0a1ca
 F src/vdbefifo.c 334c838c8f42d61a94813d136019ee566b5dc2f6
@@ -587,7 +587,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P d31f1e0d74a871d66cf7d3ef35faae5171d5cbc3
-R 0bf5660b4afc6cfd49b0db1c5f6e2c5f
+P d05eb67dd6e171cfe8b9528aa3c7c953780d8c82
+R 9acff769b3adb7f693b9b5ea49173f93
 U danielk1977
-Z 7a2e3189eb57bd7c9ad5d20204c8b8f2
+Z 8d55885cb813c4feb6a2a8686164b3b8
index d7c842e827541a247008e7bbc3731fc09836a7f2..61f7adebf2dfc7482d97aa08e56578218e52951c 100644 (file)
@@ -1 +1 @@
-d05eb67dd6e171cfe8b9528aa3c7c953780d8c82
\ No newline at end of file
+3bfee76fa6191c6e3aaa4632949b53253c612f36
\ No newline at end of file
index f4f831448f9781be6df70ab45bb0bf90264b54a1..e340f27a8a75f7f3f361cf585df8d67bf0d54489 100644 (file)
@@ -255,7 +255,8 @@ static int sqlite3Step(Vdbe *p){
   sqlite3 *db;
   int rc;
 
-  if( p==0 || p->magic!=VDBE_MAGIC_RUN ){
+  assert(p);
+  if( p->magic!=VDBE_MAGIC_RUN ){
     return SQLITE_MISUSE;
   }
 
@@ -373,47 +374,51 @@ end_of_step:
 */
 #ifdef SQLITE_OMIT_PARSER
 int sqlite3_step(sqlite3_stmt *pStmt){
-  int rc;
-  Vdbe *v;
-  v = (Vdbe*)pStmt;
-  sqlite3_mutex_enter(v->db->mutex);
-  rc = sqlite3Step(v);
-  sqlite3_mutex_leave(v->db->mutex);
+  int rc = SQLITE_MISUSE;
+  if( pStmt ){
+    Vdbe *v;
+    v = (Vdbe*)pStmt;
+    sqlite3_mutex_enter(v->db->mutex);
+    rc = sqlite3Step(v);
+    sqlite3_mutex_leave(v->db->mutex);
+  }
   return rc;
 }
 #else
 int sqlite3_step(sqlite3_stmt *pStmt){
-  int cnt = 0;
-  int rc;
-  Vdbe *v = (Vdbe*)pStmt;
-  sqlite3 *db = v->db;
-  sqlite3_mutex_enter(db->mutex);
-  while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
-         && cnt++ < 5
-         && sqlite3Reprepare(v) ){
-    sqlite3_reset(pStmt);
-    v->expired = 0;
-  }
-  if( rc==SQLITE_SCHEMA && v->zSql && db->pErr ){
-    /* This case occurs after failing to recompile an sql statement. 
-    ** The error message from the SQL compiler has already been loaded 
-    ** into the database handle. This block copies the error message 
-    ** from the database handle into the statement and sets the statement
-    ** program counter to 0 to ensure that when the statement is 
-    ** finalized or reset the parser error message is available via
-    ** sqlite3_errmsg() and sqlite3_errcode().
-    */
-    const char *zErr = (const char *)sqlite3_value_text(db->pErr); 
-    sqlite3_free(v->zErrMsg);
-    if( !db->mallocFailed ){
-      v->zErrMsg = sqlite3DbStrDup(db, zErr);
-    } else {
-      v->zErrMsg = 0;
-      v->rc = SQLITE_NOMEM;
+  int rc = SQLITE_MISUSE;
+  if( pStmt ){
+    int cnt = 0;
+    Vdbe *v = (Vdbe*)pStmt;
+    sqlite3 *db = v->db;
+    sqlite3_mutex_enter(db->mutex);
+    while( (rc = sqlite3Step(v))==SQLITE_SCHEMA
+           && cnt++ < 5
+           && sqlite3Reprepare(v) ){
+      sqlite3_reset(pStmt);
+      v->expired = 0;
+    }
+    if( rc==SQLITE_SCHEMA && v->zSql && db->pErr ){
+      /* This case occurs after failing to recompile an sql statement. 
+      ** The error message from the SQL compiler has already been loaded 
+      ** into the database handle. This block copies the error message 
+      ** from the database handle into the statement and sets the statement
+      ** program counter to 0 to ensure that when the statement is 
+      ** finalized or reset the parser error message is available via
+      ** sqlite3_errmsg() and sqlite3_errcode().
+      */
+      const char *zErr = (const char *)sqlite3_value_text(db->pErr); 
+      sqlite3_free(v->zErrMsg);
+      if( !db->mallocFailed ){
+        v->zErrMsg = sqlite3DbStrDup(db, zErr);
+      } else {
+        v->zErrMsg = 0;
+        v->rc = SQLITE_NOMEM;
+      }
     }
+    rc = sqlite3ApiExit(db, rc);
+    sqlite3_mutex_leave(db->mutex);
   }
-  rc = sqlite3ApiExit(db, rc);
-  sqlite3_mutex_leave(db->mutex);
   return rc;
 }
 #endif