Fix a couple of segfaults that could occur after a malloc() failure in the SQL compiler. (CVS 4747)

FossilOrigin-Name: 6bd8db3839d57a738cae2196679819186968b40e
This commit is contained in:
danielk1977 2008-01-23 15:44:51 +00:00
parent d2b3e23bc3
commit 15cdbebe08
4 changed files with 14 additions and 13 deletions

View File

@ -1,5 +1,5 @@
C Testing\scoverage\senhancements\sto\ssqlite3_get_table()\sand\sto\sthe\sSELECT\ncode\sgenerator.\s(CVS\s4746)
D 2008-01-23T14:51:49
C Fix\sa\scouple\sof\ssegfaults\sthat\scould\soccur\safter\sa\smalloc()\sfailure\sin\sthe\sSQL\scompiler.\s(CVS\s4747)
D 2008-01-23T15:44:51
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in bc2b5df3e3d0d4b801b824b7ef6dec43812b049b
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -132,7 +132,7 @@ F src/pragma.c 2bb8d6882b9a330e041acd05fb6aff5a01bf0a08
F src/prepare.c 1b0601ca3f97a9d253cc08697484e3045a1678e9
F src/printf.c eb27822ba2eec669161409ca31279a24c26ac910
F src/random.c 02ef38b469237482f1ea14a78b2087cfbaec48bd
F src/select.c 9c273d069d5051a4413cb55a578f01bd15f90bc8
F src/select.c 8aa0f336afc707eed9acc110e71f5efbacf5a065
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c ca06cb687c40a8bff6307b5fad41a0e86a0f8558
F src/sqlite.h.in 2a7e3776534bbe6ff2cdc058f3abebe91e7e429f
@ -367,7 +367,7 @@ F test/lock2.test 018b846f6f3b3b695fad07e317b7988442b556f4
F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9
F test/lock4.test f358fa835dff485d462072eee991111f09e87441
F test/main.test 82c222989e02ea09abd58d453828ffd71806b6bf
F test/malloc.test 010b60540ce24d90c00bcd46762f06beb80f165d
F test/malloc.test d596bd25b1d8c8a8192fdc91815b37cae3228a50
F test/malloc2.test bacb55551f6f4dc58c538589a8d3e29b127ef8d0
F test/malloc3.test 5d3839afd98bff92b82d13405f41c96e77ac2a6b
F test/malloc4.test f0e5e0f639f61e2776a6c3f5308f836b3ad8b3c7
@ -614,7 +614,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 9f95d79daeb5e7f6fd62f3c896dae4d332121d1c
R 7c8b98078b7046bd6e4e654dd28d4eae
U drh
Z cc9f9cd8eb83f3c51b585ce1808ca1e8
P 45c59802f6d35c7745b96c578ab43d5a336fe822
R 23c7c27195b1f31b653e1bbd1b07f4e2
U danielk1977
Z 05ee4244fbaa32d388c5ec67cdef8a06

View File

@ -1 +1 @@
45c59802f6d35c7745b96c578ab43d5a336fe822
6bd8db3839d57a738cae2196679819186968b40e

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.407 2008/01/23 14:51:50 drh Exp $
** $Id: select.c,v 1.408 2008/01/23 15:44:51 danielk1977 Exp $
*/
#include "sqliteInt.h"
@ -1594,7 +1594,7 @@ static int processOrderGroupBy(
sqlite3 *db = pParse->db;
ExprList *pEList;
if( pOrderBy==0 ) return 0;
if( pOrderBy==0 || pParse->db->mallocFailed ) return 0;
if( pOrderBy->nExpr>SQLITE_MAX_COLUMN ){
const char *zType = isOrder ? "ORDER" : "GROUP";
sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
@ -1624,7 +1624,7 @@ static int processOrderGroupBy(
sqlite3ExprDelete(pE);
pE = sqlite3ExprDup(db, pEList->a[iCol-1].pExpr);
pOrderBy->a[i].pExpr = pE;
if( pColl && flags ){
if( pE && pColl && flags ){
pE->pColl = pColl;
pE->flags |= flags;
}

View File

@ -16,7 +16,7 @@
# to see what happens in the library if a malloc were to really fail
# due to an out-of-memory situation.
#
# $Id: malloc.test,v 1.55 2008/01/19 23:50:26 drh Exp $
# $Id: malloc.test,v 1.56 2008/01/23 15:44:51 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -60,6 +60,7 @@ ifcapable bloblit&&subquery {
SELECT avg(b) FROM t1 GROUP BY a HAVING b>20.0;
DELETE FROM t1 WHERE a IN (SELECT min(a) FROM t1);
SELECT count(*), group_concat(e) FROM t1;
SELECT b FROM t1 ORDER BY 1 COLLATE nocase;
}
}