Skip to content

Commit

Permalink
Fix: Cleanup nodes in Thread::LinkedList(T)#delete (#15295)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden authored Dec 23, 2024
1 parent 7d15e96 commit 47b948f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/crystal/system/thread_linked_list.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ class Thread
# `#unsafe_each` until the method has returned.
def delete(node : T) : Nil
@mutex.synchronize do
if previous = node.previous
previous.next = node.next
previous = node.previous
_next = node.next

if previous
node.previous = nil
previous.next = _next
else
@head = node.next
@head = _next
end

if _next = node.next
_next.previous = node.previous
if _next
node.next = nil
_next.previous = previous
else
@tail = node.previous
@tail = previous
end
end
end
Expand Down

0 comments on commit 47b948f

Please sign in to comment.