summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-09-07 16:19:42 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-09-07 16:19:42 (GMT)
commita05766d3d315e7ecba48b10b3d24d98a7cd450df (patch)
tree4a866ebaa14a3878cab0cd22e0c654882add6131 /generic
parenta8ee2c14547d09ebb8f93ee3cea938302ea7a4c8 (diff)
downloadtcl-a05766d3d315e7ecba48b10b3d24d98a7cd450df.zip
tcl-a05766d3d315e7ecba48b10b3d24d98a7cd450df.tar.gz
tcl-a05766d3d315e7ecba48b10b3d24d98a7cd450df.tar.bz2
Improve the comments and add a test.bug_4dbdd9af14
Diffstat (limited to 'generic')
-rw-r--r--generic/tclVar.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 55eb91c..e95307e 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -4500,8 +4500,12 @@ TclDeleteNamespaceVars(
NULL, flags);
/*
- * Remove the variable from the table and force it undefined in case
- * an unset trace brought it back from the dead.
+ * We just unset the variable. However, an unset trace might
+ * have re-set it, or might have re-established traces on it.
+ * This namespace and its vartable are going away unconditionally,
+ * so we cannot let such things linger. That would be a leak.
+ *
+ * First we destroy all traces. ...
*/
if (TclIsVarTraced(varPtr)) {
@@ -4527,6 +4531,11 @@ TclDeleteNamespaceVars(
}
}
+ /*
+ * ...and then, if the variable still holds a value, we unset it
+ * again. This time with no traces left, we're sure it goes away.
+ */
+
if (!TclIsVarUndefined(varPtr)) {
UnsetVarStruct(varPtr, NULL, iPtr, /* part1 */ objPtr,
NULL, flags);