From 18d9d66f4d3a6a8b468474e25d5bacee500bda85 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 4 Jan 2013 14:38:37 +0000 Subject: Fix bad memory access problems found by Miguel Sofer when valgrinding. --- generic/tclCompCmdsSZ.c | 2 +- generic/tclEnsemble.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 7bead0d..1d04d8b 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -2737,7 +2737,7 @@ TclCompileUnsetCmd( flags = 1; varTokenPtr = TokenAfter(parsePtr->tokenPtr); leadingWord = Tcl_NewObj(); - if (TclWordKnownAtCompileTime(varTokenPtr, leadingWord)) { + if (numWords > 0 && TclWordKnownAtCompileTime(varTokenPtr, leadingWord)) { int len; const char *bytes = Tcl_GetStringFromObj(leadingWord, &len); diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c index 4e2a5cd..9a2d598 100644 --- a/generic/tclEnsemble.c +++ b/generic/tclEnsemble.c @@ -2956,9 +2956,14 @@ TclCompileEnsemble( Tcl_ListObjAppendElement(NULL, replaced, replacement); if (Tcl_ListObjGetElements(NULL, targetCmdObj, &len, &elems) != TCL_OK) { goto failed; - } - if (len != 1) { - goto failed; + } else if (len != 1) { + /* + * Note that at this point we know we can't issue any special + * instruction sequence as the mapping isn't one that we support at + * the compiled level. + */ + + goto cleanup; } targetCmdObj = elems[0]; @@ -3011,7 +3016,7 @@ TclCompileEnsemble( */ failed: - if (len == 1 && depth < 250) { + if (depth < 250) { if (depth > 1) { if (!invokeAnyway) { cmdPtr = oldCmdPtr; -- cgit v0.12