From f623729b649dc6d3c396dca6daae5aa5d88de443 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 22 Jan 2017 14:28:28 -0800 Subject: [PATCH] channeldb: fix panic in query for nonexistent channel ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a panic that would arise when the daemon attempts to query for a channel that doesn’t currently exist. The bug was the result of a typo which checked for the nil existence of the incorrect variable. --- channeldb/graph.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/channeldb/graph.go b/channeldb/graph.go index 57ee8263..8ff4da86 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -1295,21 +1295,21 @@ func fetchEdges(edgeIndex *bolt.Bucket, edges *bolt.Bucket, nodes *bolt.Bucket, chanID []byte, db *DB) (*ChannelEdge, *ChannelEdge, error) { edgeInfo := edgeIndex.Get(chanID) - if edgeIndex == nil { + if edgeInfo == nil { return nil, nil, ErrEdgeNotFound } - // The first node is contained within the first half of the - // edge information. We only propgate the error here and below if it's - // something other than edge non-existance. + // The first node is contained within the first half of the edge + // information. We only propagate the error here and below if it's + // something other than edge non-existence. node1Pub := edgeInfo[:33] edge1, err := fetchChannelEdge(edges, chanID, node1Pub, nodes) if err != nil && err != ErrEdgeNotFound { return nil, nil, err } - // As we may have a signle direction of the edge but not the other, - // only fill in the datbase pointers if the edge is found. + // As we may have a single direction of the edge but not the other, + // only fill in the database pointers if the edge is found. if edge1 != nil { edge1.db = db edge1.Node.db = db