summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2017-12-20 11:28:25 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2017-12-20 11:28:25 (GMT)
commitdc40e6f7975ff3abcea929e29493bdc7e44c1843 (patch)
tree1f32ef5a3667cc53c066e301210ac34a0cd67666 /generic
parentb6f5c151893702de2aa106b28e4ad8fe0e18ee43 (diff)
downloadtcl-dc40e6f7975ff3abcea929e29493bdc7e44c1843.zip
tcl-dc40e6f7975ff3abcea929e29493bdc7e44c1843.tar.gz
tcl-dc40e6f7975ff3abcea929e29493bdc7e44c1843.tar.bz2
Fix for issue [ba1419303b4c]: Delete a namespace for an ensemble having a deletion
trace deletes its namespace: segmentation fault.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclNamesp.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 269d06b..de10fae 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -916,6 +916,11 @@ Tcl_DeleteNamespace(
Command *cmdPtr;
/*
+ * Ensure that this namespace doesn't get deallocated in the meantime.
+ */
+ nsPtr->refCount++;
+
+ /*
* Give anyone interested - notably TclOO - a chance to use this namespace
* normally despite the fact that the namespace is going to go. Allows the
* calling of destructors. Will only be called once (unless re-established
@@ -1047,16 +1052,8 @@ Tcl_DeleteNamespace(
#endif
Tcl_DeleteHashTable(&nsPtr->cmdTable);
- /*
- * If the reference count is 0, then discard the namespace.
- * Otherwise, mark it as "dead" so that it can't be used.
- */
-
- if (!nsPtr->refCount) {
- NamespaceFree(nsPtr);
- } else {
- nsPtr->flags |= NS_DEAD;
- }
+ nsPtr ->flags |= NS_DEAD;
+ TclNsDecrRefCount(nsPtr);
} else {
/*
* Restore the ::errorInfo and ::errorCode traces.