From 627f95403f0cfb348aa9c5de361878a05351ab16 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Fri, 7 Jan 2022 13:54:47 -0600 Subject: [PATCH] Pass loop variable to defer function The loop variable changes before the defer executes, so we need to pass it to the function to make sure the closure has the correct version of the loop variable. --- core/rawdb/plugin_hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/rawdb/plugin_hooks.go b/core/rawdb/plugin_hooks.go index 3de55cc40..523e95deb 100644 --- a/core/rawdb/plugin_hooks.go +++ b/core/rawdb/plugin_hooks.go @@ -43,7 +43,7 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) { } for i := min ; i < num; i++ { update, ok := freezerUpdates[i] - defer func() { delete(freezerUpdates, i) }() + defer func(i uint64) { delete(freezerUpdates, i) }(i) if !ok { log.Warn("Attempting to commit untracked block", "num", i) continue