diff options
| author | pooryorick <com.digitalsmarties@pooryorick.com> | 2020-08-12 13:28:08 (GMT) |
|---|---|---|
| committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2020-08-12 13:28:08 (GMT) |
| commit | 1d4f551278f3f36f063591ecc1a6bd2e7964b14f (patch) | |
| tree | e1fe6781e3e2a5cbb0f2944b71d7c2f43161303c | |
| parent | b3f8c269fa4910edabe381bf6ec17ecdb2bb19e1 (diff) | |
| download | tcl-1d4f551278f3f36f063591ecc1a6bd2e7964b14f.zip tcl-1d4f551278f3f36f063591ecc1a6bd2e7964b14f.tar.gz tcl-1d4f551278f3f36f063591ecc1a6bd2e7964b14f.tar.bz2 | |
Fix for [3422267ed6b7], segmentation fault with imported alias.
| -rw-r--r-- | generic/tclNamesp.c | 7 | ||||
| -rw-r--r-- | generic/tclProc.c | 7 | ||||
| -rw-r--r-- | tests/interp.test | 7 |
3 files changed, 20 insertions, 1 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 26dca62..fea23aa 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -959,7 +959,7 @@ Tcl_DeleteNamespace( /* * If the namespace has associated ensemble commands, delete them first. * This leaves the actual contents of the namespace alone (unless they are - * linked ensemble commands, of course). Note that this code is actually + * linked ensemble commands, of course). This code is * reentrant so command delete traces won't purturb things badly. */ @@ -1770,7 +1770,9 @@ DoImport( TclInvokeImportedCmd, InvokeImportedNRCmd, dataPtr, DeleteImportedCmd); dataPtr->realCmdPtr = cmdPtr; + cmdPtr->refCount++; dataPtr->selfPtr = (Command *) importedCmd; + dataPtr->selfPtr->refCount++; dataPtr->selfPtr->compileProc = cmdPtr->compileProc; Tcl_DStringFree(&ds); @@ -1781,6 +1783,7 @@ DoImport( refPtr = (ImportRef *)ckalloc(sizeof(ImportRef)); refPtr->importedCmdPtr = (Command *) importedCmd; + refPtr->importedCmdPtr->refCount++; refPtr->nextPtr = cmdPtr->importRefPtr; cmdPtr->importRefPtr = refPtr; } else { @@ -2076,7 +2079,9 @@ DeleteImportedCmd( } else { prevPtr->nextPtr = refPtr->nextPtr; } + TclCleanupCommandMacro(refPtr->importedCmdPtr); ckfree(refPtr); + TclCleanupCommandMacro(selfPtr) ckfree(dataPtr); return; } diff --git a/generic/tclProc.c b/generic/tclProc.c index 0d67c37..150d036 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -215,6 +215,7 @@ Tcl_ProcObjCmd( */ procPtr->cmdPtr = (Command *) cmd; + procPtr->cmdPtr->refCount++; /* * TIP #280: Remember the line the procedure body is starting on. In a @@ -2154,6 +2155,12 @@ TclProcCleanupProc( ckfree(localPtr); localPtr = nextPtr; } + /* + * TclOOMethod.c:clOOMakeProcMethod sets cmdPtr to NULL + */ + if (procPtr->cmdPtr) { + TclCleanupCommandMacro(procPtr->cmdPtr); + } ckfree(procPtr); /* diff --git a/tests/interp.test b/tests/interp.test index 599ac08..35f3390 100644 --- a/tests/interp.test +++ b/tests/interp.test @@ -3664,6 +3664,13 @@ test interp-38.8 {interp debug basic setup} -body { } -returnCodes { error } -result {wrong # args: should be "interp debug path ?-frame ?bool??"} + +test interp-39.0 { + no segmentation fault when a command is deleted +} -body { +} -cleanup { +} -result 1 + # cleanup unset -nocomplain hidden_cmds |
