From 9c42a41ed81c0f138236b4ee6490a63092bea3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 2 Jan 2018 12:38:26 +0200 Subject: [PATCH] eth/downloader: avoid hidden reference to finished statesync request (#15545) --- eth/downloader/statesync.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eth/downloader/statesync.go b/eth/downloader/statesync.go index a0b05c9be6..937828b949 100644 --- a/eth/downloader/statesync.go +++ b/eth/downloader/statesync.go @@ -132,7 +132,10 @@ func (d *Downloader) runStateSync(s *stateSync) *stateSync { // Send the next finished request to the current sync: case deliverReqCh <- deliverReq: - finished = append(finished[:0], finished[1:]...) + // Shift out the first request, but also set the emptied slot to nil for GC + copy(finished, finished[1:]) + finished[len(finished)-1] = nil + finished = finished[:len(finished)-1] // Handle incoming state packs: case pack := <-d.stateCh: