diff options
author | dgp <dgp@users.sourceforge.net> | 2014-02-06 22:38:17 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-02-06 22:38:17 (GMT) |
commit | 6e78f7a617b001eb5e35fe11cad2f469c0f48320 (patch) | |
tree | 1dcd49e5460f08137bd685f431b862090082fc7b /generic/tclBasic.c | |
parent | 4ae04fa40387165f811a88d87a1140a07bf10215 (diff) | |
download | tcl-6e78f7a617b001eb5e35fe11cad2f469c0f48320.zip tcl-6e78f7a617b001eb5e35fe11cad2f469c0f48320.tar.gz tcl-6e78f7a617b001eb5e35fe11cad2f469c0f48320.tar.bz2 |
[a4494e28ed] Use flag bit instead of NULL pointer to suppress teardown list of
imported commands when the original command gets re-created. This prevents the
panic otherwise possible when the invalid state represented by the NULL pointer
is encountered during a command delete trace.
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r-- | generic/tclBasic.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index c3ab871..89d6b8f 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -1887,10 +1887,19 @@ Tcl_CreateCommand( */ cmdPtr = Tcl_GetHashValue(hPtr); - oldRefPtr = cmdPtr->importRefPtr; - cmdPtr->importRefPtr = NULL; + cmdPtr->refCount++; + if (cmdPtr->importRefPtr) { + cmdPtr->flags |= CMD_REDEF_IN_PROGRESS; + } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) cmdPtr); + + if (cmdPtr->flags & CMD_REDEF_IN_PROGRESS) { + oldRefPtr = cmdPtr->importRefPtr; + cmdPtr->importRefPtr = NULL; + } + TclCleanupCommandMacro(cmdPtr); + hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew); if (!isNew) { /* @@ -2061,10 +2070,19 @@ Tcl_CreateObjCommand( * intact. */ - oldRefPtr = cmdPtr->importRefPtr; - cmdPtr->importRefPtr = NULL; + cmdPtr->refCount++; + if (cmdPtr->importRefPtr) { + cmdPtr->flags |= CMD_REDEF_IN_PROGRESS; + } Tcl_DeleteCommandFromToken(interp, (Tcl_Command) cmdPtr); + + if (cmdPtr->flags & CMD_REDEF_IN_PROGRESS) { + oldRefPtr = cmdPtr->importRefPtr; + cmdPtr->importRefPtr = NULL; + } + TclCleanupCommandMacro(cmdPtr); + hPtr = Tcl_CreateHashEntry(&nsPtr->cmdTable, tail, &isNew); if (!isNew) { /* @@ -2869,12 +2887,13 @@ Tcl_DeleteCommandFromToken( * commands were created that refer back to this command. Delete these * imported commands now. */ - - for (refPtr = cmdPtr->importRefPtr; refPtr != NULL; - refPtr = nextRefPtr) { - nextRefPtr = refPtr->nextPtr; - importCmd = (Tcl_Command) refPtr->importedCmdPtr; - Tcl_DeleteCommandFromToken(interp, importCmd); + if (!(cmdPtr->flags & CMD_REDEF_IN_PROGRESS)) { + for (refPtr = cmdPtr->importRefPtr; refPtr != NULL; + refPtr = nextRefPtr) { + nextRefPtr = refPtr->nextPtr; + importCmd = (Tcl_Command) refPtr->importedCmdPtr; + Tcl_DeleteCommandFromToken(interp, importCmd); + } } /* |