summaryrefslogtreecommitdiffstats
path: root/generic/tclCompExpr.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-04-25 19:07:06 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-04-25 19:07:06 (GMT)
commitbc808f183f4c2b6328fe0d9d44396e1147795f84 (patch)
tree4dbeedb071952dd90f94bae207260b6127fdb9c9 /generic/tclCompExpr.c
parent878b93bf45b4a7326999b5cd61afbe084895a0aa (diff)
downloadtcl-bc808f183f4c2b6328fe0d9d44396e1147795f84.zip
tcl-bc808f183f4c2b6328fe0d9d44396e1147795f84.tar.gz
tcl-bc808f183f4c2b6328fe0d9d44396e1147795f84.tar.bz2
* generic/tclCompExpr.c (ParseExpr): Revised to be sure that
an error return doesn't prevent all literals getting placed on the litList to be returned to the caller for freeing. Corrects some memleaks. [Bug 1705778, leak K23]
Diffstat (limited to 'generic/tclCompExpr.c')
-rw-r--r--generic/tclCompExpr.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c
index b373969..f24c505 100644
--- a/generic/tclCompExpr.c
+++ b/generic/tclCompExpr.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCompExpr.c,v 1.52 2007/04/24 15:36:42 dgp Exp $
+ * RCS: @(#) $Id: tclCompExpr.c,v 1.53 2007/04/25 19:07:07 dgp Exp $
*/
#include "tclInt.h"
@@ -349,6 +349,22 @@ ParseExpr(
const char *end;
int wordIndex;
+ /*
+ * Store away any literals on the list now, so they'll
+ * be available for our caller to free if we error out
+ * of this routine. [Bug 1705778, leak K23]
+ */
+
+ switch (lexeme) {
+ case NUMBER:
+ case BOOLEAN:
+ Tcl_ListObjAppendElement(NULL, litList, literal);
+ numLiterals++;
+ break;
+ default:
+ break;
+ }
+
if (lastWas < 0) {
msg = Tcl_ObjPrintf("missing operator at %s", mark);
if (lastStart[0] == '0') {
@@ -369,8 +385,6 @@ ParseExpr(
switch (lexeme) {
case NUMBER:
case BOOLEAN:
- Tcl_ListObjAppendElement(NULL, litList, literal);
- numLiterals++;
lastWas = OT_LITERAL;
start += scanned;
numBytes -= scanned;