From cd39f34fa58e57741ef315b5f9587783ea6331a3 Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 11 Mar 2018 18:08:00 +0000 Subject: Attempt at providing the missing instance squelcher. --- generic/tclOO.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/generic/tclOO.c b/generic/tclOO.c index c6ea91d..556ad80 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -934,10 +934,26 @@ ReleaseClassContents( TclDecrRefCount(filterObj); } ckfree(clsPtr->filters.list); + clsPtr->filters.list = NULL; clsPtr->filters.num = 0; } /* + * Squelch our instances. + */ + + if (clsPtr->instances.num) { + Object *oPtr; + + FOREACH(oPtr, clsPtr->instances) { + TclOODecrRefCount(oPtr); + } + ckfree(clsPtr->instances.list); + clsPtr->instances.list = NULL; + clsPtr->instances.num = 0; + } + + /* * Squelch our metadata. */ -- cgit v0.12 From e7a5b8aaa5817974ac8a090530f79af42ea60544 Mon Sep 17 00:00:00 2001 From: dgp Date: Sun, 11 Mar 2018 21:14:41 +0000 Subject: Prevent leaks of the Object structs of oo::object and oo::class. --- generic/tclOO.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/generic/tclOO.c b/generic/tclOO.c index 556ad80..587e46d 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -552,6 +552,15 @@ KillFoundation( { Foundation *fPtr = GetFoundation(interp); + /* + * Crude mechanism to avoid leaking the Object struct of the + * foundation components oo::object and oo::class + * + * Should probably be replaced with something more elegantly designed. + */ + while (TclOODecrRefCount(fPtr->objectCls->thisPtr) == 0) {}; + while (TclOODecrRefCount(fPtr->classCls->thisPtr) == 0) {}; + TclDecrRefCount(fPtr->unknownMethodNameObj); TclDecrRefCount(fPtr->constructorName); TclDecrRefCount(fPtr->destructorName); -- cgit v0.12