Skip to content

Commit

Permalink
Fix a reference leak in collections.RBTree.__root__
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed Nov 11, 2023
1 parent 821024d commit 17d2e96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/dex/collections/rbtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions util/test-errors.dee
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
}
Expand Down Expand Up @@ -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);
}


Expand Down

0 comments on commit 17d2e96

Please sign in to comment.