From 9dcd98ad9c51fee46aee2b84976cf9281ad2a503 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 18 May 2018 16:21:06 -0700 Subject: [PATCH] contractcourt: prevent scoping bug by re-binding channel pointer In this commit, we attempt to fix a bug that's possible within the Start() method of the ChainArbiter. We pass the channel pointer directly into the newActiveChannelArbitrator function causing it to close over the loop variable. We later use the channel point directly to send messages to other sub-systems. It's possible that we actually have the shadowed loop variable and will send an incorrect message. Defensively, we now re-bind the loop variable in order to ensure we point to the proper channel. --- contractcourt/chain_arbitrator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 1f7e90b8..aa9a956a 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -330,6 +330,7 @@ func (c *ChainArbitrator) Start() error { // ChannelArbitrator. for _, channel := range openChannels { chanPoint := channel.FundingOutpoint + channel := channel // First, we'll create an active chainWatcher for this channel // to ensure that we detect any relevant on chain events.