]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix another segfault that can occur following a malloc failure in the SQL compiler...
authordanielk1977 <danielk1977@noemail.net>
Wed, 23 Jan 2008 17:13:40 +0000 (17:13 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 23 Jan 2008 17:13:40 +0000 (17:13 +0000)
FossilOrigin-Name: 9d98a3f0dded4ee7ed53872f48ee8592ff077f92

manifest
manifest.uuid
src/select.c
test/malloc.test

index e20aa9fec93565d227c0aa45506a239f32215d42..3110dd87cc235e589b244b5cd4c8eb0c04a80ece 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-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
+C Fix\sanother\ssegfault\sthat\scan\soccur\sfollowing\sa\smalloc\sfailure\sin\sthe\sSQL\scompiler.\s(CVS\s4748)
+D 2008-01-23T17:13:41
 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 8aa0f336afc707eed9acc110e71f5efbacf5a065
+F src/select.c cf9243f67fcd70349181deff97f7774c5f63cb51
 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 d596bd25b1d8c8a8192fdc91815b37cae3228a50
+F test/malloc.test 72b7bec7906ff11f72ad81a0575c16fcf4094d04
 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 45c59802f6d35c7745b96c578ab43d5a336fe822
-R 23c7c27195b1f31b653e1bbd1b07f4e2
+P 6bd8db3839d57a738cae2196679819186968b40e
+R 0cea1a07ac3b7597749c9337fddee227
 U danielk1977
-Z 05ee4244fbaa32d388c5ec67cdef8a06
+Z a6a6578ea50042aa916ced737f8619d2
index a9c67f964e92afdc12b66bf8acfa68bc71ef742e..8ef27914e35c33a7af42877963ee874c15d09588 100644 (file)
@@ -1 +1 @@
-6bd8db3839d57a738cae2196679819186968b40e
\ No newline at end of file
+9d98a3f0dded4ee7ed53872f48ee8592ff077f92
\ No newline at end of file
index 49d179cf2cff9b5519afd5b41b746298f4724280..f22527585c687ac0c4e504f05cf146a9f14b5f3c 100644 (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.408 2008/01/23 15:44:51 danielk1977 Exp $
+** $Id: select.c,v 1.409 2008/01/23 17:13:41 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -1676,15 +1676,15 @@ static int processCompoundOrderBy(
   while( pSelect && moreToDo ){
     moreToDo = 0;
     for(i=0; i<pOrderBy->nExpr; i++){
-      int iCol;
+      int iCol = -1;
       Expr *pE, *pDup;
       if( pOrderBy->a[i].done ) continue;
       pE = pOrderBy->a[i].pExpr;
       pDup = sqlite3ExprDup(db, pE);
-      if( pDup==0 ){
-        return 1;
+      if( !db->mallocFailed ){
+        assert(pDup);
+        iCol = matchOrderByTermToExprList(pParse, pSelect, pDup, i+1, 1, 0);
       }
-      iCol = matchOrderByTermToExprList(pParse, pSelect, pDup, i+1, 1, 0);
       sqlite3ExprDelete(pDup);
       if( iCol<0 ){
         return 1;
index 47e2fa2d70eaca31361676d6b32c9a7a82309137..f95af331f3350776f0751551a42aa3000ebeb218 100644 (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.56 2008/01/23 15:44:51 danielk1977 Exp $
+# $Id: malloc.test,v 1.57 2008/01/23 17:13:41 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -573,6 +573,14 @@ ifcapable {pager_pragmas} {
   }
 }
 
+ifcapable compound {
+  do_malloc_test 24 -start 19 -sqlprep {
+    CREATE TABLE t1(a, b, c)
+  } -sqlbody {
+    SELECT 1 FROM t1 UNION SELECT 2 FROM t1 ORDER BY 1
+  }
+}
+
 # Ensure that no file descriptors were leaked.
 do_test malloc-99.X {
   catch {db close}