Skip to content

Commit c462454

Browse files
committed
internal/task: fix nil panic in (*internal/task.Stack).Pop
While adding some code to clear the Next field when popping from a task stack for safety reasons, the clear was placed outside of a nil pointer check. As a result, (*internal/task.Stack).Pop panicked when the Stack is empty.
1 parent 499781c commit c462454

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/internal/task/queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func (s *Stack) Pop() *Task {
6868
t := s.top
6969
if t != nil {
7070
s.top = t.Next
71+
t.Next = nil
7172
}
72-
t.Next = nil
7373
return t
7474
}
7575

0 commit comments

Comments
 (0)