summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-07-19 16:35:59 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-07-19 16:35:59 (GMT)
commiteacbc736d923a9b9b77f628876dac58ad34dfd10 (patch)
tree856bc1201a32ad2c13a02076460fd6cf7c49ec18
parent1bd8f407a5fc44a8b7a54bb78d8d29a2e5b0358f (diff)
parentb32141b751698c59b7c8b574b52963976f3e0dd4 (diff)
downloadtcl-eacbc736d923a9b9b77f628876dac58ad34dfd10.zip
tcl-eacbc736d923a9b9b77f628876dac58ad34dfd10.tar.gz
tcl-eacbc736d923a9b9b77f628876dac58ad34dfd10.tar.bz2
[75b8433707] Revised fix for memleak in oo instance list management.
-rw-r--r--generic/tclOO.c7
-rw-r--r--tests/oo.test13
2 files changed, 20 insertions, 0 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c
index de00733..02e00c9 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -1008,6 +1008,12 @@ ReleaseClassContents(
}
if (!Deleted(instancePtr)) {
Tcl_DeleteCommandFromToken(interp, instancePtr->command);
+ /*
+ * Tcl_DeleteCommandFromToken() may have done to whole
+ * job for us. Roll back and check again.
+ */
+ i--;
+ continue;
}
DelRef(instancePtr);
}
@@ -1280,6 +1286,7 @@ TclOORemoveFromInstances(
removeInstance:
if (Deleted(clsPtr->thisPtr)) {
+ DelRef(clsPtr->instances.list[i]);
clsPtr->instances.list[i] = NULL;
} else {
clsPtr->instances.num--;
diff --git a/tests/oo.test b/tests/oo.test
index d63e931..fcd9818 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -258,6 +258,19 @@ test oo-1.18 {OO: create object in NS with same name as global cmd} -setup {
rename test-oo-1.18 {}
A destroy
} -result ::C
+test oo-1.18.1 {Bug 75b8433707: memory leak in oo-1.18} -setup {
+ proc test-oo-1.18 {} return
+} -constraints memory -body {
+ leaktest {
+ oo::class create A
+ oo::class create B {superclass A}
+ oo::define B constructor {} {A create test-oo-1.18}
+ B create C
+ A destroy
+ }
+} -cleanup {
+ rename test-oo-1.18 {}
+} -result 0
test oo-1.19 {basic test of OO functionality: teardown order} -body {
oo::object create o
namespace delete [info object namespace o]