From: Leandro Lucarella Date: Tue, 19 Jul 2011 02:02:25 +0000 (-0300) Subject: Don't leak weak pointers X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/commitdiff_plain/68f7d87cf5eae6f656e43bb8472b555755a9cef4 Don't leak weak pointers The free() call after the return is never executed, so we have to move it inside the locked() block of code. --- diff --git a/rt/gc/cdgc/gc.d b/rt/gc/cdgc/gc.d index e6b3c11..98e5899 100644 --- a/rt/gc/cdgc/gc.d +++ b/rt/gc/cdgc/gc.d @@ -1981,8 +1981,8 @@ void weakpointerDestroy( void* p ) return locked!(void, () { if (wp.reference) rt_detachDisposeEvent(wp.reference, &wp.ondestroy); + cstdlib.free(wp); })(); - cstdlib.free(wp); } }