core: assign zero after resize in implementations of heap.Interface #26296 (#1841)

This commit is contained in:
Daniel Liu 2025-12-11 18:48:55 +08:00 committed by GitHub
parent d75f2822d3
commit d3e994377b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -46,6 +46,7 @@ func (h *nonceHeap) Pop() interface{} {
old := *h
n := len(old)
x := old[n-1]
old[n-1] = 0 // avoid memory leak
*h = old[0 : n-1]
return x
}

View file

@ -704,6 +704,7 @@ func (s *TxByPriceAndTime) Pop() interface{} {
old := s.txs
n := len(old)
x := old[n-1]
old[n-1] = nil // avoid memory leak
s.txs = old[0 : n-1]
return x
}