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

Fix some segfaults that could have occurred after a malloc() failure. (CVS 1661)

FossilOrigin-Name: 80151e728101c3cd5a8cf36cca2bfa661b21c746
This commit is contained in:
drh
2004-06-22 13:22:40 +00:00
parent d1e3bee1a0
commit 645f63ed02
6 changed files with 17 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
C Add\scrash.test\sscript.\s(CVS\s1660) C Fix\ssome\ssegfaults\sthat\scould\shave\soccurred\safter\sa\smalloc()\sfailure.\s(CVS\s1661)
D 2004-06-22T13:12:52 D 2004-06-22T13:22:40
F Makefile.in 0a3d7aaefa50717bd550b0cf568a51072c4c103c F Makefile.in 0a3d7aaefa50717bd550b0cf568a51072c4c103c
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -28,7 +28,7 @@ F src/attach.c 05102e2e8ac43ce639d07b47a99c7772a62420e6
F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217 F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217
F src/btree.c 0cf8a52a57a7eb13d50719114ee1fa353e89d7d3 F src/btree.c 0cf8a52a57a7eb13d50719114ee1fa353e89d7d3
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5 F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
F src/build.c baed8f54ea9fb785cb798dc6600b07697b8595d4 F src/build.c fc0b51748da8bc9c8266fdb36e57d49393793947
F src/date.c b3e8b2bef1e3f2ce24e5b057203036defb18c3f1 F src/date.c b3e8b2bef1e3f2ce24e5b057203036defb18c3f1
F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3 F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
@@ -68,16 +68,16 @@ F src/test3.c 7247090d15a5a43823079b6fd8dad1ed3cccdedf
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2 F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
F src/test5.c 1b7c275b2929dbd034a567255d2aca339410d1d6 F src/test5.c 1b7c275b2929dbd034a567255d2aca339410d1d6
F src/tokenize.c 900374b6b37f04748bcd48c2d29a41c251542935 F src/tokenize.c 900374b6b37f04748bcd48c2d29a41c251542935
F src/trigger.c 368fb2953bef9399273c67bca283914822de8762 F src/trigger.c 296e888ae931e9774e1761996b2b66db40f7d216
F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
F src/utf.c 3a2596013e4b9582d075ca742de7f067ff7dee95 F src/utf.c 3a2596013e4b9582d075ca742de7f067ff7dee95
F src/util.c e31e35d3d76cab7a02045095064897eca49cbce3 F src/util.c e31e35d3d76cab7a02045095064897eca49cbce3
F src/vacuum.c fcb930215a3f6c50087300782555f61ad11dd80c F src/vacuum.c fcb930215a3f6c50087300782555f61ad11dd80c
F src/vdbe.c 5da73f61016b1874d935b522bab6ca8b5aa15216 F src/vdbe.c 4fd24e030878888962a7da383639eb1af4a0e087
F src/vdbe.h 2d87155e31e84bb00cdc48cc1ce6987a3a484250 F src/vdbe.h 2d87155e31e84bb00cdc48cc1ce6987a3a484250
F src/vdbeInt.h 0b8eda5e0a1331d23b38d7888f187119a3491b40 F src/vdbeInt.h 0b8eda5e0a1331d23b38d7888f187119a3491b40
F src/vdbeapi.c d3659f3f2982e79c06ab8e338604a39e0ea0d2d3 F src/vdbeapi.c d3659f3f2982e79c06ab8e338604a39e0ea0d2d3
F src/vdbeaux.c 9fe01087f2ddc410827b6e124fc423d429e6f5a1 F src/vdbeaux.c a7831608f895a4756e937d9a002ef5270ee7a2a0
F src/vdbemem.c 9359c53386e070fea9f5403cab0c6f0cfe36496b F src/vdbemem.c 9359c53386e070fea9f5403cab0c6f0cfe36496b
F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
@@ -228,7 +228,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl af528563442e3039928f9018327a18157e53a44f F www/version3.tcl af528563442e3039928f9018327a18157e53a44f
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P be6bd6c99dde902aafd02d8a72f3d42826caabe8 P 64a6d805178af8947ccca19898c06979c226d92b
R e0f8cd78ed0c1d3c7e04b2acf0370248 R 8a2991bd99cf63f67057ae040d7bd05a
U danielk1977 U drh
Z c3503634057680b2d410b0fe073781d0 Z 77d0fbc0eeda0f21673a68ba50db4d18

View File

@@ -1 +1 @@
64a6d805178af8947ccca19898c06979c226d92b 80151e728101c3cd5a8cf36cca2bfa661b21c746

View File

@@ -23,7 +23,7 @@
** ROLLBACK ** ROLLBACK
** PRAGMA ** PRAGMA
** **
** $Id: build.c,v 1.231 2004/06/22 12:18:32 danielk1977 Exp $ ** $Id: build.c,v 1.232 2004/06/22 13:22:40 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -121,6 +121,7 @@ Table *sqlite3FindTable(sqlite *db, const char *zName, const char *zDatabase){
Table *p = 0; Table *p = 0;
int i; int i;
int rc = sqlite3ReadSchema(db, 0); int rc = sqlite3ReadSchema(db, 0);
assert( zName!=0 );
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue; if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue;

View File

@@ -79,7 +79,7 @@ void sqlite3BeginTrigger(
** If sqlite3SrcListLookup() returns 0, indicating the table does not ** If sqlite3SrcListLookup() returns 0, indicating the table does not
** exist, the error is caught by the block below. ** exist, the error is caught by the block below.
*/ */
if( !pTableName ) goto trigger_cleanup; if( !pTableName || sqlite3_malloc_failed ) goto trigger_cleanup;
pTab = sqlite3SrcListLookup(pParse, pTableName); pTab = sqlite3SrcListLookup(pParse, pTableName);
if( pName2->n==0 && pTab && pTab->iDb==1 ){ if( pName2->n==0 && pTab && pTab->iDb==1 ){
iDb = 1; iDb = 1;

View File

@@ -43,7 +43,7 @@
** in this file for details. If in doubt, do not deviate from existing ** in this file for details. If in doubt, do not deviate from existing
** commenting and indentation practices when changing or adding code. ** commenting and indentation practices when changing or adding code.
** **
** $Id: vdbe.c,v 1.385 2004/06/21 11:30:56 danielk1977 Exp $ ** $Id: vdbe.c,v 1.386 2004/06/22 13:22:41 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include "os.h" #include "os.h"
@@ -185,20 +185,6 @@ static int AggInsert(Agg *p, char *zKey, int nKey){
return 0; return 0;
} }
/*
** Get the AggElem currently in focus
*/
#if 0
#define AggInFocus(P) ((P).pCurrent ? (P).pCurrent : _AggInFocus(&(P)))
static AggElem *_AggInFocus(Agg *p){
HashElem *pElem = sqliteHashFirst(&p->hash);
if( pElem==0 ){
AggInsert(p,"",1);
pElem = sqliteHashFirst(&p->hash);
}
return pElem ? sqliteHashData(pElem) : 0;
}
#endif
/* /*
** Store a pointer to the AggElem currently in focus in *ppElem. Return ** Store a pointer to the AggElem currently in focus in *ppElem. Return
** SQLITE_OK if successful, otherwise an error-code. ** SQLITE_OK if successful, otherwise an error-code.
@@ -4223,7 +4209,7 @@ case OP_AggReset: {
if( pOp->p1 ){ if( pOp->p1 ){
rc = sqlite3VdbeAggReset(0, &p->agg, (KeyInfo *)pOp->p3); rc = sqlite3VdbeAggReset(0, &p->agg, (KeyInfo *)pOp->p3);
p->agg.nMem = pOp->p2; /* Agg.nMem is used by AggInsert() */ p->agg.nMem = pOp->p2; /* Agg.nMem is used by AggInsert() */
AggInsert(&p->agg, 0, 0); rc = AggInsert(&p->agg, 0, 0);
}else{ }else{
rc = sqlite3VdbeAggReset(db, &p->agg, (KeyInfo *)pOp->p3); rc = sqlite3VdbeAggReset(db, &p->agg, (KeyInfo *)pOp->p3);
p->agg.nMem = pOp->p2; p->agg.nMem = pOp->p2;

View File

@@ -679,7 +679,7 @@ void freeAggElem(AggElem *pElem, Agg *pAgg){
int i; int i;
for(i=0; i<pAgg->nMem; i++){ for(i=0; i<pAgg->nMem; i++){
Mem *pMem = &pElem->aMem[i]; Mem *pMem = &pElem->aMem[i];
if( pAgg->apFunc[i] && (pMem->flags & MEM_AggCtx)!=0 ){ if( pAgg->apFunc && pAgg->apFunc[i] && (pMem->flags & MEM_AggCtx)!=0 ){
sqlite3_context ctx; sqlite3_context ctx;
ctx.pFunc = pAgg->apFunc[i]; ctx.pFunc = pAgg->apFunc[i];
ctx.s.flags = MEM_Null; ctx.s.flags = MEM_Null;