From 620695542c4699a7df4fdeb9110fee65677f9fc7 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 15 May 2017 17:53:22 -0700 Subject: [PATCH] peer: fix panic bug in watiForChanToClose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a panic bug in the watiForChanToClose method caused by a logic error leading to the return value of the function at times being a nil pointer in the case that an error occurred. We now avoid such an error by _always_ returning from the function if there’s an error, but conditionally (in a diff if-clause) sending an error over the error channel. --- peer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/peer.go b/peer.go index ee6f22c0..e4c9b843 100644 --- a/peer.go +++ b/peer.go @@ -1069,8 +1069,10 @@ func waitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, // TODO(roasbeef): add param for num needed confs confNtfn, err := notifier.RegisterConfirmationsNtfn(closingTxID, 1, bestHeight) - if err != nil && errChan != nil { - errChan <- err + if err != nil { + if errChan != nil { + errChan <- err + } return }