diff options
| author | pooryorick <com.digitalsmarties@pooryorick.com> | 2020-08-16 10:04:44 (GMT) |
|---|---|---|
| committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2020-08-16 10:04:44 (GMT) |
| commit | a5455c136a2b022903089f85ebc28327fe31898e (patch) | |
| tree | 60718f99fa9a4454b75f299d4f3712ccca43a0bb /generic/tclBasic.c | |
| parent | acfbbfa01955b1e6807428aef20496d83af43d17 (diff) | |
| download | tcl-a5455c136a2b022903089f85ebc28327fe31898e.zip tcl-a5455c136a2b022903089f85ebc28327fe31898e.tar.gz tcl-a5455c136a2b022903089f85ebc28327fe31898e.tar.bz2 | |
Fix for [688fcc7082fa], memory error during deletion of imported routine.
Diffstat (limited to 'generic/tclBasic.c')
| -rw-r--r-- | generic/tclBasic.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 4ee2ca0..2b1bae9 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -3547,6 +3547,19 @@ Tcl_DeleteCommandFromToken( iPtr->compileEpoch++; } + if (!(cmdPtr->flags & CMD_REDEF_IN_PROGRESS)) { + /* + * Delete any imports of this routine before deleting this routine itself. + * See issue 688fcc7082fa. + */ + for (refPtr = cmdPtr->importRefPtr; refPtr != NULL; + refPtr = nextRefPtr) { + nextRefPtr = refPtr->nextPtr; + importCmd = (Tcl_Command) refPtr->importedCmdPtr; + Tcl_DeleteCommandFromToken(interp, importCmd); + } + } + if (cmdPtr->deleteProc != NULL) { /* * Delete the command's client data. If this was an imported command @@ -3567,20 +3580,6 @@ Tcl_DeleteCommandFromToken( } /* - * If this command was imported into other namespaces, then imported - * commands were created that refer back to this command. Delete these - * imported commands now. - */ - 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); - } - } - - /* * Don't use hPtr to delete the hash entry here, because it's possible * that the deletion callback renamed the command. Instead, use * cmdPtr->hptr, and make sure that no-one else has already deleted the |
