aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroharboe <oharboe>2009-08-16 11:37:03 +0000
committeroharboe <oharboe>2009-08-16 11:37:03 +0000
commitd0c5df9ca126ccd1dbc40f75e33b016859d0bfe6 (patch)
treec3bef8ca2e069c56c74bac589d9fbc32f1ffec44
parent5d231b9a3cac7de53a7a4c8c6fc88ef96b26d40b (diff)
downloadjimtcl-d0c5df9ca126ccd1dbc40f75e33b016859d0bfe6.zip
jimtcl-d0c5df9ca126ccd1dbc40f75e33b016859d0bfe6.tar.gz
jimtcl-d0c5df9ca126ccd1dbc40f75e33b016859d0bfe6.tar.bz2
2009-08-16 Steve Bennett <steveb@workware.net.au>
* jim.c/h: If an object is used in subst, then source, a crash will result
-rw-r--r--ChangeLog1
-rw-r--r--jim.c8
-rw-r--r--jim.h3
3 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e89b906..0019bcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
2009-08-16 Steve Bennett <steveb@workware.net.au>
+ * jim.c/h: If an object is used in subst, then source, a crash will result
* jimsh.c: A script exiting with 'exit 0' would not give a return code of 0
* jim.c: Make [format %c 0] work (embedded nulls)
* jim-array-1.0.tcl: array unset was broken
diff --git a/jim.c b/jim.c
index 4708054..9f75861 100644
--- a/jim.c
+++ b/jim.c
@@ -3012,6 +3012,7 @@ int SetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
script->commands = 0;
script->token = NULL;
script->cmdStruct = NULL;
+ script->substFlags = 0;
script->inUse = 1;
/* Try to get information about filename / line number */
if (objPtr->typePtr == &sourceObjType) {
@@ -3116,12 +3117,15 @@ int SetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
Jim_FreeIntRep(interp, objPtr);
Jim_SetIntRepPtr(objPtr, script);
objPtr->typePtr = &scriptObjType;
+
return JIM_OK;
}
ScriptObj *Jim_GetScript(Jim_Interp *interp, Jim_Obj *objPtr)
{
- if (objPtr->typePtr != &scriptObjType) {
+ struct ScriptObj *script = Jim_GetIntRepPtr(objPtr);
+
+ if (objPtr->typePtr != &scriptObjType || script->substFlags) {
SetScriptFromAny(interp, objPtr);
}
return (ScriptObj*) Jim_GetIntRepPtr(objPtr);
@@ -11617,7 +11621,7 @@ static int Jim_LoadCoreCommand(Jim_Interp *interp, int argc,
static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
- int i, flags = 0;
+ int i, flags = JIM_SUBST_FLAG;
Jim_Obj *objPtr;
if (argc < 2) {
diff --git a/jim.h b/jim.h
index 7ee8235..b9e4d7b 100644
--- a/jim.h
+++ b/jim.h
@@ -3,7 +3,7 @@
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
* Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
* Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
- * Copyright 2008 oharboe - Øyvind Harboe - oyvind.harboe@zylin.com
+ * Copyright 2008 oharboe - �yvind Harboe - oyvind.harboe@zylin.com
* Copyright 2008 Andrew Lunn <andrew@lunn.ch>
* Copyright 2008 Duane Ellis <openocd@duaneellis.com>
* Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
@@ -176,6 +176,7 @@ extern "C" {
#define JIM_SUBST_NOVAR 1 /* don't perform variables substitutions */
#define JIM_SUBST_NOCMD 2 /* don't perform command substitutions */
#define JIM_SUBST_NOESC 4 /* don't perform escapes substitutions */
+#define JIM_SUBST_FLAG 128 /* flag to indicate that this is a real substition object */
/* Unused arguments generate annoying warnings... */
#define JIM_NOTUSED(V) ((void) V)