From bc808f183f4c2b6328fe0d9d44396e1147795f84 Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 25 Apr 2007 19:07:06 +0000 Subject: * 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] --- ChangeLog | 7 +++++++ generic/tclCompExpr.c | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f336f0f..23169c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-25 Don Porter + + * 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] + 2007-04-25 Daniel Steffen * unix/Makefile.in (dist): add macosx/*.xcconfig files to src dist; 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; -- cgit v0.12