Fix a memory leak on ORDER BY of a compound select caused by the resolver
on a flattened query. Also fix a OOM segfault in WHERE clause processing. (CVS 5801)
FossilOrigin-Name: d2c252d6bbde4ae14da6c9e6c2683d763d11c59f
diff --git a/src/expr.c b/src/expr.c
index c076094..52f7cdb 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
-** $Id: expr.c,v 1.398 2008/10/07 19:53:14 drh Exp $
+** $Id: expr.c,v 1.399 2008/10/11 16:47:36 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -601,16 +601,24 @@
}
/*
-** Recursively delete an expression tree.
+** Clear an expression structure without deleting the structure itself.
+** Substructure is deleted.
*/
-void sqlite3ExprDelete(sqlite3 *db, Expr *p){
- if( p==0 ) return;
+void sqlite3ExprClear(sqlite3 *db, Expr *p){
if( p->span.dyn ) sqlite3DbFree(db, (char*)p->span.z);
if( p->token.dyn ) sqlite3DbFree(db, (char*)p->token.z);
sqlite3ExprDelete(db, p->pLeft);
sqlite3ExprDelete(db, p->pRight);
sqlite3ExprListDelete(db, p->pList);
sqlite3SelectDelete(db, p->pSelect);
+}
+
+/*
+** Recursively delete an expression tree.
+*/
+void sqlite3ExprDelete(sqlite3 *db, Expr *p){
+ if( p==0 ) return;
+ sqlite3ExprClear(db, p);
sqlite3DbFree(db, p);
}