1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Fix handling of a failed malloc() in various places (CVS 1604)

FossilOrigin-Name: 7d8edce4c12d075acbc6bac6758aabb2769f983a
This commit is contained in:
danielk1977
2004-06-16 10:39:23 +00:00
parent eac7a362f6
commit 5c4c77878d
4 changed files with 24 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
C Fix\stwo\smore\smemory\sleaks.\s(CVS\s1603) C Fix\shandling\sof\sa\sfailed\smalloc()\sin\svarious\splaces\s(CVS\s1604)
D 2004-06-16T07:45:24 D 2004-06-16T10:39:24
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -33,12 +33,12 @@ F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58 F src/delete.c 911221aadb35d610c84fadb32e71c52990827e58
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
F src/expr.c 7c19fbc4495f8978439c20528cf3e070df068427 F src/expr.c 7c19fbc4495f8978439c20528cf3e070df068427
F src/func.c 60bf9412807f95d4694863114ae7009d817de45f F src/func.c be055fc63f1ae59c6a5dc4901240669f2a21f40c
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
F src/main.c da573d5b157dbb376349efcb4ff2cbe830f80c80 F src/main.c adac42394fb42aa47e3fdc5d9354d21f4bdaf29a
F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1 F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1
F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
@@ -224,7 +224,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P e9a77f8972128550f6ff98dcf854eb7680eaee8b P 98b48704a1ce983677cdb269c24f7bca4ed606f7
R 925b12cad91290c34145812d35712b79 R f0197c8c4720736cb4c2834534e1d0e2
U danielk1977 U danielk1977
Z 728cd56f54fcbd121f4ed570a3126bce Z 6139ebf902566b13c2ee3227a615ae8b

View File

@@ -1 +1 @@
98b48704a1ce983677cdb269c24f7bca4ed606f7 7d8edce4c12d075acbc6bac6758aabb2769f983a

View File

@@ -16,7 +16,7 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope. ** 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 <ctype.h>
#include <math.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 *pArg = (Mem *)argv[0];
Mem *pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest)); 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 ){ if( pBest->flags ){
CollSeq *pColl = sqlite3GetFuncCollSeq(context); CollSeq *pColl = sqlite3GetFuncCollSeq(context);
/* This step function is used for both the min() and max() aggregates, /* This step function is used for both the min() and max() aggregates,

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** 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 "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -471,6 +471,10 @@ int sqlite3_last_statement_changes(sqlite *db){
void sqlite3_close(sqlite *db){ void sqlite3_close(sqlite *db){
HashElem *i; HashElem *i;
int j; int j;
if( !db ){
return;
}
db->want_to_close = 1; db->want_to_close = 1;
/* FIX ME: db->magic may be set to SQLITE_MAGIC_CLOSED if the database /* 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){ int sqlite3_errcode(sqlite3 *db){
if( !db ) return SQLITE_NOMEM;
return db->errCode; return db->errCode;
} }
@@ -937,6 +942,8 @@ int sqlite3_prepare(
char *zErrMsg = 0; char *zErrMsg = 0;
int rc = SQLITE_OK; int rc = SQLITE_OK;
assert( ppStmt );
*ppStmt = 0;
if( sqlite3SafetyOn(db) ){ if( sqlite3SafetyOn(db) ){
rc = SQLITE_MISUSE; rc = SQLITE_MISUSE;
goto prepare_out; goto prepare_out;
@@ -995,8 +1002,6 @@ int sqlite3_prepare(
if( sParse.rc==SQLITE_SCHEMA ){ if( sParse.rc==SQLITE_SCHEMA ){
sqlite3ResetInternalSchema(db, 0); sqlite3ResetInternalSchema(db, 0);
} }
assert( ppStmt );
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
if( pzTail ) *pzTail = sParse.zTail; if( pzTail ) *pzTail = sParse.zTail;
rc = sParse.rc; rc = sParse.rc;
@@ -1013,6 +1018,12 @@ prepare_out:
if( sqlite3SafetyOff(db) ){ if( sqlite3SafetyOff(db) ){
rc = SQLITE_MISUSE; rc = SQLITE_MISUSE;
} }
if( rc==SQLITE_OK ){
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
}else if( sParse.pVdbe ){
sqlite3_finalize(sParse.pVdbe);
}
if( zErrMsg ){ if( zErrMsg ){
sqlite3Error(db, rc, "%s", zErrMsg); sqlite3Error(db, rc, "%s", zErrMsg);
sqliteFree(zErrMsg); sqliteFree(zErrMsg);