]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix handling of a failed malloc() in various places (CVS 1604)
authordanielk1977 <danielk1977@noemail.net>
Wed, 16 Jun 2004 10:39:23 +0000 (10:39 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 16 Jun 2004 10:39:23 +0000 (10:39 +0000)
FossilOrigin-Name: 7d8edce4c12d075acbc6bac6758aabb2769f983a

manifest
manifest.uuid
src/func.c
src/main.c

index 287708ef0e2ea8c678dbeceac0097e877e92b139..3504207f915a38a62f3ad79f542a01175abf5ab0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\stwo\smore\smemory\sleaks.\s(CVS\s1603)
-D 2004-06-16T07:45:24
+C Fix\shandling\sof\sa\sfailed\smalloc()\sin\svarious\splaces\s(CVS\s1604)
+D 2004-06-16T10:39:24
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -33,12 +33,12 @@ F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
 F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58
 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
 F src/expr.c 7c19fbc4495f8978439c20528cf3e070df068427
-F src/func.c 60bf9412807f95d4694863114ae7009d817de45f
+F src/func.c be055fc63f1ae59c6a5dc4901240669f2a21f40c
 F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
 F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
 F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a
 F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
-F src/main.c da573d5b157dbb376349efcb4ff2cbe830f80c80
+F src/main.c adac42394fb42aa47e3fdc5d9354d21f4bdaf29a
 F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
 F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1
 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
@@ -224,7 +224,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P e9a77f8972128550f6ff98dcf854eb7680eaee8b
-R 925b12cad91290c34145812d35712b79
+P 98b48704a1ce983677cdb269c24f7bca4ed606f7
+R f0197c8c4720736cb4c2834534e1d0e2
 U danielk1977
-Z 728cd56f54fcbd121f4ed570a3126bce
+Z 6139ebf902566b13c2ee3227a615ae8b
index e57d2d68228b63d45e1ec91270cbcd4a086e73c1..94c4fb841b80b753b901f40361f3bc21c74f53f5 100644 (file)
@@ -1 +1 @@
-98b48704a1ce983677cdb269c24f7bca4ed606f7
\ No newline at end of file
+7d8edce4c12d075acbc6bac6758aabb2769f983a
\ No newline at end of file
index 4f639540ecf0590874a588332ce08fc714a4a1ad..e4660ecabd41542e1d58501f7944fb02c6ad2159 100644 (file)
@@ -16,7 +16,7 @@
 ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
 ** All other code has file scope.
 **
-** $Id: func.c,v 1.69 2004/06/15 13:36:30 danielk1977 Exp $
+** $Id: func.c,v 1.70 2004/06/16 10:39:24 danielk1977 Exp $
 */
 #include <ctype.h>
 #include <math.h>
@@ -904,8 +904,7 @@ static void minmaxStep(sqlite3_context *context, int argc, sqlite3_value **argv)
   Mem *pArg  = (Mem *)argv[0];
   Mem *pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest));
 
-  if( SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
-
+  if( !pBest || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
   if( pBest->flags ){
     CollSeq *pColl = sqlite3GetFuncCollSeq(context);
     /* This step function is used for both the min() and max() aggregates,
index e3ae84bdb330e7fda6866969e41ed9c1dea9c6f0..fc44eae380f7d517d1296c8be53c36dcc9f09f89 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.222 2004/06/15 16:51:01 danielk1977 Exp $
+** $Id: main.c,v 1.223 2004/06/16 10:39:32 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -471,6 +471,10 @@ int sqlite3_last_statement_changes(sqlite *db){
 void sqlite3_close(sqlite *db){
   HashElem *i;
   int j;
+
+  if( !db ){
+    return;
+  }
   db->want_to_close = 1;
 
   /* FIX ME: db->magic may be set to SQLITE_MAGIC_CLOSED if the database
@@ -892,6 +896,7 @@ const void *sqlite3_errmsg16(sqlite3 *db){
 }
 
 int sqlite3_errcode(sqlite3 *db){
+  if( !db ) return SQLITE_NOMEM;
   return db->errCode;
 }
 
@@ -937,6 +942,8 @@ int sqlite3_prepare(
   char *zErrMsg = 0;
   int rc = SQLITE_OK;
 
+  assert( ppStmt );
+  *ppStmt = 0;
   if( sqlite3SafetyOn(db) ){
     rc = SQLITE_MISUSE;
     goto prepare_out;
@@ -995,8 +1002,6 @@ int sqlite3_prepare(
   if( sParse.rc==SQLITE_SCHEMA ){
     sqlite3ResetInternalSchema(db, 0);
   }
-  assert( ppStmt );
-  *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
   if( pzTail ) *pzTail = sParse.zTail;
   rc = sParse.rc;
 
@@ -1013,6 +1018,12 @@ prepare_out:
   if( sqlite3SafetyOff(db) ){
     rc = SQLITE_MISUSE;
   }
+  if( rc==SQLITE_OK ){
+    *ppStmt = (sqlite3_stmt*)sParse.pVdbe;
+  }else if( sParse.pVdbe ){
+    sqlite3_finalize(sParse.pVdbe);
+  }
+
   if( zErrMsg ){
     sqlite3Error(db, rc, "%s", zErrMsg);
     sqliteFree(zErrMsg);