Skip to content

Commit 47b948f

Browse files
authored
Fix: Cleanup nodes in Thread::LinkedList(T)#delete (#15295)
1 parent 7d15e96 commit 47b948f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/crystal/system/thread_linked_list.cr

+11-6
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,21 @@ class Thread
4747
# `#unsafe_each` until the method has returned.
4848
def delete(node : T) : Nil
4949
@mutex.synchronize do
50-
if previous = node.previous
51-
previous.next = node.next
50+
previous = node.previous
51+
_next = node.next
52+
53+
if previous
54+
node.previous = nil
55+
previous.next = _next
5256
else
53-
@head = node.next
57+
@head = _next
5458
end
5559

56-
if _next = node.next
57-
_next.previous = node.previous
60+
if _next
61+
node.next = nil
62+
_next.previous = previous
5863
else
59-
@tail = node.previous
64+
@tail = previous
6065
end
6166
end
6267
end

0 commit comments

Comments
 (0)