summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-08-23 19:35:53 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-08-23 19:35:53 (GMT)
commitbb9f3f7aa9e2a821f747e9fadd74b12c47deb819 (patch)
tree5290369646d79c6004f69043ee80382eb4809c27 /generic
parentd27177f503461d6e868ebc79d00179424f51836f (diff)
downloadtcl-bb9f3f7aa9e2a821f747e9fadd74b12c47deb819.zip
tcl-bb9f3f7aa9e2a821f747e9fadd74b12c47deb819.tar.gz
tcl-bb9f3f7aa9e2a821f747e9fadd74b12c47deb819.tar.bz2
* generic/tclCompCmds.c (TclCompileReturnCmd): Added crash protection
to handle callers other than TclCompileScript() failing to meet the initialization assumptions of the TIP 280 code in CompileWord().
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCompCmds.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c
index 9748a60..f920c87 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.114 2007/07/31 17:03:36 msofer Exp $
+ * RCS: @(#) $Id: tclCompCmds.c,v 1.115 2007/08/23 19:35:54 dgp Exp $
*/
#include "tclInt.h"
@@ -24,6 +24,9 @@
*
* static void CompileWord(CompileEnv *envPtr, Tcl_Token *tokenPtr,
* Tcl_Interp *interp, int word);
+ *
+ * NOTE: Take care to keep this macro definition in sync with the
+ * expansion found in TclCompileReturnCmd().
*/
#define CompileWord(envPtr, tokenPtr, interp, word) \
@@ -3137,7 +3140,31 @@ TclCompileReturnCmd(
*/
if (explicitResult) {
- CompileWord(envPtr, wordTokenPtr, interp, numWords-1);
+
+ /*
+ * This used to be the macro call
+ *
+ * CompileWord(envPtr, wordTokenPtr, interp, numWords-1);
+ *
+ * That has been replaced with the following expansion so that
+ * we can handle the case (eclIndex < 0), which happens when
+ * callers other than the central TclCompileScript compiler
+ * engine call this routine. Those other callers do not take
+ * care to initialize things in envPtr to the liking of the
+ * TIP 280 handling code in the unmodified CompileWord macro,
+ * so crash protection is needed here.
+ */
+
+ if (wordTokenPtr->type == TCL_TOKEN_SIMPLE_WORD) {
+ TclEmitPush(TclRegisterNewLiteral(envPtr, wordTokenPtr[1].start,
+ wordTokenPtr[1].size), envPtr);
+ } else {
+ if (eclIndex >= 0) {
+ envPtr->line = mapPtr->loc[eclIndex].line[numWords-1];
+ }
+ TclCompileTokens(interp, wordTokenPtr+1,
+ wordTokenPtr->numComponents, envPtr);
+ }
} else {
/*
* No explict result argument, so default result is empty string.