1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix a segfault that may follow a malloc failure during compilation of an INSTEAD OF trigger. (CVS 4749)

FossilOrigin-Name: c6635a71dbb2a06d56a0cfce7f0383325e12dc01
This commit is contained in:
danielk1977
2008-01-24 14:27:44 +00:00
parent ac559264e3
commit cdf3020ca3
4 changed files with 27 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
C Fix\sanother\ssegfault\sthat\scan\soccur\sfollowing\sa\smalloc\sfailure\sin\sthe\sSQL\scompiler.\s(CVS\s4748) C Fix\sa\ssegfault\sthat\smay\sfollow\sa\smalloc\sfailure\sduring\scompilation\sof\san\sINSTEAD\sOF\strigger.\s(CVS\s4749)
D 2008-01-23T17:13:41 D 2008-01-24T14:27:44
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -132,7 +132,7 @@ F src/pragma.c 2bb8d6882b9a330e041acd05fb6aff5a01bf0a08
F src/prepare.c 1b0601ca3f97a9d253cc08697484e3045a1678e9 F src/prepare.c 1b0601ca3f97a9d253cc08697484e3045a1678e9
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910 F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
F src/select.c cf9243f67fcd70349181deff97f7774c5f63cb51 F src/select.c 00adbc4fbb573d90e35cd475e41f0c5190d066e8
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c ca06cb687c40a8bff6307b5fad41a0e86a0f8558 F src/shell.c ca06cb687c40a8bff6307b5fad41a0e86a0f8558
F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
@@ -367,7 +367,7 @@ F test/lock2.test 018b846f6f3b3b695fad07e317b7988442b556f4
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/lock4.test f358fa835dff485d462072eee991111f09e87441 F test/lock4.test f358fa835dff485d462072eee991111f09e87441
F test/main.test 82c222989e02ea09abd58d453828ffd71806b6bf F test/main.test 82c222989e02ea09abd58d453828ffd71806b6bf
F test/malloc.test 72b7bec7906ff11f72ad81a0575c16fcf4094d04 F test/malloc.test 13ab98fb05dbc260a9a1bd6f92a071572b0069da
F test/malloc2.test bacb55551f6f4dc58c538589a8d3e29b127ef8d0 F test/malloc2.test bacb55551f6f4dc58c538589a8d3e29b127ef8d0
F test/malloc3.test 5d3839afd98bff92b82d13405f41c96e77ac2a6b F test/malloc3.test 5d3839afd98bff92b82d13405f41c96e77ac2a6b
F test/malloc4.test f0e5e0f639f61e2776a6c3f5308f836b3ad8b3c7 F test/malloc4.test f0e5e0f639f61e2776a6c3f5308f836b3ad8b3c7
@@ -614,7 +614,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 6bd8db3839d57a738cae2196679819186968b40e P 9d98a3f0dded4ee7ed53872f48ee8592ff077f92
R 0cea1a07ac3b7597749c9337fddee227 R b6bc9b4a6b48ed3d43db1ee3750fa526
U danielk1977 U danielk1977
Z a6a6578ea50042aa916ced737f8619d2 Z 9d3a54981e45b2a55afee41615486d59

View File

@@ -1 +1 @@
9d98a3f0dded4ee7ed53872f48ee8592ff077f92 c6635a71dbb2a06d56a0cfce7f0383325e12dc01

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite. ** to handle SELECT statements in SQLite.
** **
** $Id: select.c,v 1.409 2008/01/23 17:13:41 danielk1977 Exp $ ** $Id: select.c,v 1.410 2008/01/24 14:27:44 danielk1977 Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -2911,12 +2911,12 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
** special value 0xffffffff, then all columns are populated. ** special value 0xffffffff, then all columns are populated.
*/ */
void sqlite3SelectMask(Parse *pParse, Select *p, u32 mask){ void sqlite3SelectMask(Parse *pParse, Select *p, u32 mask){
if( !p->pPrior && !p->isDistinct && mask!=0xffffffff ){ if( p && !p->pPrior && !p->isDistinct && mask!=0xffffffff ){
ExprList *pEList; ExprList *pEList;
int i; int i;
sqlite3SelectResolve(pParse, p, 0); sqlite3SelectResolve(pParse, p, 0);
pEList = p->pEList; pEList = p->pEList;
for(i=0; i<pEList->nExpr && i<32; i++){ for(i=0; pEList && i<pEList->nExpr && i<32; i++){
if( !(mask&((u32)1<<i)) ){ if( !(mask&((u32)1<<i)) ){
sqlite3ExprDelete(pEList->a[i].pExpr); sqlite3ExprDelete(pEList->a[i].pExpr);
pEList->a[i].pExpr = sqlite3Expr(pParse->db, TK_NULL, 0, 0, 0); pEList->a[i].pExpr = sqlite3Expr(pParse->db, TK_NULL, 0, 0, 0);

View File

@@ -16,7 +16,7 @@
# to see what happens in the library if a malloc were to really fail # to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation. # due to an out-of-memory situation.
# #
# $Id: malloc.test,v 1.57 2008/01/23 17:13:41 danielk1977 Exp $ # $Id: malloc.test,v 1.58 2008/01/24 14:27:44 danielk1977 Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -574,13 +574,27 @@ ifcapable {pager_pragmas} {
} }
ifcapable compound { ifcapable compound {
do_malloc_test 24 -start 19 -sqlprep { do_malloc_test 24 -sqlprep {
CREATE TABLE t1(a, b, c) CREATE TABLE t1(a, b, c)
} -sqlbody { } -sqlbody {
SELECT 1 FROM t1 UNION SELECT 2 FROM t1 ORDER BY 1 SELECT 1 FROM t1 UNION SELECT 2 FROM t1 ORDER BY 1
} }
} }
ifcapable view&&trigger {
do_malloc_test 25 -sqlprep {
CREATE TABLE t1(a, b, c);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TRIGGER v1t1 INSTEAD OF DELETE ON v1 BEGIN SELECT 1; END;
CREATE TRIGGER v1t2 INSTEAD OF INSERT ON v1 BEGIN SELECT 1; END;
CREATE TRIGGER v1t3 INSTEAD OF UPDATE ON v1 BEGIN SELECT 1; END;
} -sqlbody {
DELETE FROM v1 WHERE a = 1;
INSERT INTO v1 VALUES(1, 2, 3);
UPDATE v1 SET a = 1 WHERE b = 2;
}
}
# Ensure that no file descriptors were leaked. # Ensure that no file descriptors were leaked.
do_test malloc-99.X { do_test malloc-99.X {
catch {db close} catch {db close}