From 00a4da3b8c0e277851b552aa4374881ce3ca9dca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 16 Feb 2017 20:45:01 +0800 Subject: [PATCH] htlcswitch: fix panic when receiving close req for unknown channel --- htlcswitch.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htlcswitch.go b/htlcswitch.go index 84347369..5af74485 100644 --- a/htlcswitch.go +++ b/htlcswitch.go @@ -658,8 +658,13 @@ func (h *htlcSwitch) handleCloseLink(req *closeLinkReq) { // channel's available bandwidth by the delta specified within the message. func (h *htlcSwitch) handleLinkUpdate(req *linkInfoUpdateMsg) { h.chanIndexMtx.RLock() - link := h.chanIndex[*req.targetLink] + link, ok := h.chanIndex[*req.targetLink] h.chanIndexMtx.RUnlock() + if !ok { + hswcLog.Errorf("received link update for non-existent link: %v", + req.targetLink) + return + } atomic.AddInt64(&link.availableBandwidth, int64(req.bandwidthDelta))