From 0346db3d28f76c5cd9878c41fe7401b3eddc9c68 Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Mon, 23 Apr 2007 19:04:41 +0000 Subject: * generic/tclCompCmds.c (TclCompileUpvarCmd): Plugged a memory leak in 'upvar' when compiling (a) upvar outside a proc, (b) upvar with a syntax error, or (c) upvar where the frame index is not known at compile time. * generic/tclParseExpr.c (ParseExpr): Plugged a memory leak when parsing expressions that contain syntax errors. --- ChangeLog | 9 +++++++-- generic/tclCompCmds.c | 5 ++++- generic/tclCompExpr.c | 7 +++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7af153..b2498af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,12 @@ 2007-04-23 Kevin B. Kenny + * generic/tclCompCmds.c (TclCompileUpvarCmd): Plugged a memory + leak in 'upvar' when compiling (a) upvar outside a proc, (b) + upvar with a syntax error, or (c) upvar where the frame index + is not known at compile time. + * generic/tclParseExpr.c (ParseExpr): Plugged a memory leak + when parsing expressions that contain syntax errors. * generic/tclEnv.c (ReplaceString): Clear memory correctly when growing the cache to avoid reads of uninitialised data. * generic/tclStrToD.c (AccumulateDecimalDigit): Fixed a mistake @@ -12,10 +18,9 @@ a number begins with a string of more than 'maxpow10_wide' zeroes. * generic/tclTest.c (Testregexpobjcmd): Removed an invalid access beyond the end of 'objv' in 'testregexp -about'. - All three of these issues reported under [Bug 1705778] - detected with + All of these issues reported under [Bug 1705778] - detected with the existing test suite, no new regression tests required. ->>>>>>> 1.3453 2007-04-22 Miguel Sofer * generic/tclVar.c (TclDeleteNamespaceVars): fixed access to freed diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 04f6bd5..8651432 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompCmds.c,v 1.108 2007/04/15 18:59:34 kennykb Exp $ + * RCS: @(#) $Id: tclCompCmds.c,v 1.109 2007/04/23 19:04:42 kennykb Exp $ */ #include "tclInt.h" @@ -5366,11 +5366,13 @@ TclCompileUpvarCmd( Tcl_Obj *objPtr = Tcl_NewObj(); if (envPtr->procPtr == NULL) { + Tcl_DecrRefCount(objPtr); return TCL_ERROR; } numWords = parsePtr->numWords; if (numWords < 3) { + Tcl_DecrRefCount(objPtr); return TCL_ERROR; } @@ -5409,6 +5411,7 @@ TclCompileUpvarCmd( i = 3; } } else { + Tcl_DecrRefCount(objPtr); return TCL_ERROR; } diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index e5cddb3..6acf13e 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.50 2007/04/17 14:49:53 dkf Exp $ + * RCS: @(#) $Id: tclCompExpr.c,v 1.51 2007/04/23 19:04:43 kennykb Exp $ */ #include "tclInt.h" @@ -202,7 +202,7 @@ ParseExpr( * those operands that require run time * substitutions. */ { - OpNode *nodes; + OpNode *nodes = NULL; int nodesAvailable = 64, nodesUsed = 0; int code = TCL_OK; int numLiterals = 0, numFuncs = 0; @@ -723,6 +723,9 @@ ParseExpr( numBytes -= scanned; } + if (code != TCL_OK && nodes != NULL) { + ckfree((char*) nodes); + } if (code == TCL_OK) { *opTreePtr = nodes; } else if (interp == NULL) { -- cgit v0.12