From 17d2e964dda6c708df713c59dc78ece17705913f Mon Sep 17 00:00:00 2001 From: GrieferAtWork Date: Sat, 11 Nov 2023 19:07:25 +0100 Subject: [PATCH] Fix a reference leak in `collections.RBTree.__root__` --- src/dex/collections/rbtree.c | 8 ++++---- util/test-errors.dee | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/dex/collections/rbtree.c b/src/dex/collections/rbtree.c index b304f7794..eb4f93144 100644 --- a/src/dex/collections/rbtree.c +++ b/src/dex/collections/rbtree.c @@ -1120,8 +1120,6 @@ rbtree_iter(RBTree *__restrict self) { result = DeeObject_MALLOC(RBTreeIterator); if unlikely(!result) goto done; - result->rbti_tree = self; - Dee_Incref(self); RBTree_LockRead(self); result->rbti_version = self->rbt_version; result->rbti_next = self->rbt_root; @@ -1131,6 +1129,8 @@ rbtree_iter(RBTree *__restrict self) { result->rbti_next = result->rbti_next->rbtn_lhs; } RBTree_LockEndRead(self); + result->rbti_tree = self; + Dee_Incref(self); DeeObject_Init(result, &RBTreeIterator_Type); done: return result; @@ -3030,14 +3030,14 @@ rbtree_get_itroot(RBTree *__restrict self) { result = DeeObject_MALLOC(RBTreeIterator); if unlikely(!result) goto done; - result->rbti_tree = self; - Dee_Incref(self); RBTree_LockRead(self); if unlikely(!self->rbt_root) goto err_r_unlock_empty; result->rbti_next = self->rbt_root; result->rbti_version = self->rbt_version; RBTree_LockEndRead(self); + result->rbti_tree = self; + Dee_Incref(self); DeeObject_Init(result, &RBTreeIterator_Type); done: return result; diff --git a/util/test-errors.dee b/util/test-errors.dee index 328d88c15..7066061d1 100644 --- a/util/test-errors.dee +++ b/util/test-errors.dee @@ -276,8 +276,8 @@ function invokeTypeMembers(t: Type) { continue; local wrapper = t.operator . (a.name); if (wrapper is Callable) { - //print(f"invokeAsync({repr wrapper});"); - invoke(wrapper, name: f"{repr t}.{a.name}"); + print(f"invokeAsync({repr wrapper});"); + //invoke(wrapper, name: f"{repr t}.{a.name}"); } } } @@ -308,8 +308,7 @@ function main() { //invokeTypeMembers((UniqueDict from collections).Frozen); //invokeTypeMembers((UniqueSet from collections)); //invokeTypeMembers((UniqueSet from collections).Frozen); - // FIXME: This leaks references somewhere - invokeTypeMembers(RBTree from collections); + //invokeTypeMembers(RBTree from collections); }