aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2006-01-07 14:02:26 +0000
committerdanielk1977 <danielk1977@noemail.net>2006-01-07 14:02:26 +0000
commitdba99bcc964233d7b8ac7d480c929c7874a03f83 (patch)
tree4086b9c6797940f2e4630940d85b5cb7905232ff
parentc00da105654fb2bd0712acccac3e36b539805d08 (diff)
downloadsqlite-dba99bcc964233d7b8ac7d480c929c7874a03f83.tar.gz
sqlite-dba99bcc964233d7b8ac7d480c929c7874a03f83.zip
Fix some memory leaks caused by obscure syntax errors in SQL. (CVS 2882)
FossilOrigin-Name: 6593199a4d0d0e1f9cc2f48d30327b1c03a8170e
-rw-r--r--manifest14
-rw-r--r--manifest.uuid2
-rw-r--r--src/parse.y7
-rw-r--r--test/expr.test15
4 files changed, 27 insertions, 11 deletions
diff --git a/manifest b/manifest
index 3c23686ee..5071bf0aa 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C In\sshared-cache\smode,\slock\sall\srequired\stables\sbefore\sbeginning\sto\sexecute\sthe\sbody\sof\sthe\sstatement\sprogram.\s(CVS\s2881)
-D 2006-01-07T13:21:04
+C Fix\ssome\smemory\sleaks\scaused\sby\sobscure\ssyntax\serrors\sin\sSQL.\s(CVS\s2882)
+D 2006-01-07T14:02:27
F Makefile.in c79fbdaa264c6afcd435f2fb492551de5a8cf80d
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -61,7 +61,7 @@ F src/os_win.c 88f372bf093b3257f54d2d7710f00cfcae86fb9d
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c f06b85eb1e43bb2e6a7a5108ac8346576b4b78fa
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
-F src/parse.y 58258759fabdd48f1d2561e276097290b1ea2680
+F src/parse.y 83df51fea35f68f7e07384d75dce83d1ed30434c
F src/pragma.c ae8b135531e7a4d692c60bd909c819d0b3fc588a
F src/prepare.c fef89dc92703d345251142af966b60e44a66cfc5
F src/printf.c f47a2f4b5387cd2ebb12e9117a1a5d6bd9a2b812
@@ -153,7 +153,7 @@ F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b
F test/enc.test 7a03417a1051fe8bc6c7641cf4c8c3f7e0066d52
F test/enc2.test 6ea55732ddffd340f3d3a29cc33645e9ded481c7
F test/enc3.test f6a5f0b7b7f3a88f030d3143729b87cd5c86d837
-F test/expr.test 06381174d8c25fbbfd9ed335fe0cde835d39123d
+F test/expr.test a513aceb5d89042232e0d07ac5a1591965cf3963
F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
F test/format4.test 9f31d41d4f926cab97b2ebe6be00a6ab12dece87
F test/func.test a7119afcc16abdf24b24486684fb888279008f75
@@ -335,7 +335,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 77ac231c0e21c09c0b612a4e72bcc863f2c95fd3
-R a3383f6d4bdf9c6fcebb44953df9373f
+P 23b587b05b89727248805e6d9e5141e018cf2152
+R b9ef38eb9219972e18666035e7ca732b
U danielk1977
-Z 6669b8779258a46a23e7780534ef4f13
+Z 5df6fea511267cf56eade3a5959a2ec5
diff --git a/manifest.uuid b/manifest.uuid
index b12a96548..25cb21922 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-23b587b05b89727248805e6d9e5141e018cf2152 \ No newline at end of file
+6593199a4d0d0e1f9cc2f48d30327b1c03a8170e \ No newline at end of file
diff --git a/src/parse.y b/src/parse.y
index e7d13e865..0a242fdb9 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
-** @(#) $Id: parse.y,v 1.191 2006/01/04 15:54:36 drh Exp $
+** @(#) $Id: parse.y,v 1.192 2006/01/07 14:02:27 danielk1977 Exp $
*/
// All token codes are small integers with #defines that begin with "TK_"
@@ -685,6 +685,7 @@ expr(A) ::= expr(X) CONCAT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);}
likeop(A) ::= LIKE_KW(X). {A.operator = X; A.not = 0;}
likeop(A) ::= NOT LIKE_KW(X). {A.operator = X; A.not = 1;}
%type escape {Expr*}
+%destructor escape {sqlite3ExprDelete($$);}
escape(X) ::= ESCAPE expr(A). [ESCAPE] {X = A;}
escape(X) ::= . [ESCAPE] {X = 0;}
expr(A) ::= expr(X) likeop(OP) expr(Y) escape(E). [LIKE_KW] {
@@ -817,9 +818,11 @@ case_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {
A = sqlite3ExprListAppend(A, Z, 0);
}
%type case_else {Expr*}
+%destructor case_else {sqlite3ExprDelete($$);}
case_else(A) ::= ELSE expr(X). {A = X;}
case_else(A) ::= . {A = 0;}
%type case_operand {Expr*}
+%destructor case_operand {sqlite3ExprDelete($$);}
case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = 0;}
@@ -940,6 +943,7 @@ foreach_clause(A) ::= FOR EACH ROW. { A = TK_ROW; }
foreach_clause(A) ::= FOR EACH STATEMENT. { A = TK_STATEMENT; }
%type when_clause {Expr*}
+%destructor when_clause {sqlite3ExprDelete($$);}
when_clause(A) ::= . { A = 0; }
when_clause(A) ::= WHEN expr(X). { A = X; }
@@ -1003,6 +1007,7 @@ cmd ::= ATTACH database_kw_opt expr(F) AS expr(D) key_opt(K). {
sqlite3Attach(pParse, F, D, K);
}
%type key_opt {Expr *}
+%destructor key_opt {sqlite3ExprDelete($$);}
key_opt(A) ::= . { A = 0; }
key_opt(A) ::= KEY expr(X). { A = X; }
diff --git a/test/expr.test b/test/expr.test
index a54cce35c..6f9209807 100644
--- a/test/expr.test
+++ b/test/expr.test
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing expressions.
#
-# $Id: expr.test,v 1.48 2005/11/14 22:29:06 drh Exp $
+# $Id: expr.test,v 1.49 2006/01/07 14:02:27 danielk1977 Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -633,6 +633,17 @@ do_test expr-11.2 {
execsql {SELECT typeof(9223372036854775808)}
} {real}
-
+# These two statements used to leak memory (because of missing %destructor
+# directives in parse.y).
+do_test expr-12.1 {
+ catchsql {
+ SELECT (CASE a>4 THEN 1 ELSE 0 END) FROM test1;
+ }
+} {1 {near "THEN": syntax error}}
+do_test expr-12.2 {
+ catchsql {
+ SELECT (CASE WHEN a>4 THEN 1 ELSE 0) FROM test1;
+ }
+} {1 {near ")": syntax error}}
finish_test