Skip to content

Commit cbc470e

Browse files
committed
Fix queue potential bugs
1 parent 18585de commit cbc470e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

queue.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,11 @@ func (q *LinkedListQueue) Shift() (interface{}, error) {
420420
if q.first == nil {
421421
q.last = nil
422422
}
423-
val := node.Val
423+
val := *node.Val
424424

425425
q.recycleNode(node)
426426

427-
return *val, nil
427+
return val, nil
428428
}
429429

430430
// Unshift Unshift the val to the first position(non-blocking)
@@ -460,10 +460,10 @@ func (q *LinkedListQueue) Pop() (interface{}, error) {
460460
if q.last == nil {
461461
q.first = nil
462462
}
463-
val := node.Val
463+
val := *node.Val
464464
q.recycleNode(node)
465465

466-
return *val, nil
466+
return val, nil
467467
}
468468

469469
// Push Push the data to the last position(non-blocking)

0 commit comments

Comments
 (0)