From ed40eddafd5d7b1663912f49b41f2567bc1a3771 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 16 Jun 2022 10:10:27 +0200 Subject: [PATCH 1/2] autopilot: return early for empty graph This fixes an issue where the diameter calculation would crash if the graph is empty. --- autopilot/simple_graph.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autopilot/simple_graph.go b/autopilot/simple_graph.go index f7bf4c12c..08476414b 100644 --- a/autopilot/simple_graph.go +++ b/autopilot/simple_graph.go @@ -132,6 +132,11 @@ func (graph *SimpleGraph) shortestPathLengths(node int) map[int]uint32 { // thisLevel contains the nodes that are explored in the round. thisLevel := make([]int, 0, graphOrder) + // Abort if we have an empty graph. + if len(graph.Adj) == 0 { + return seen + } + // We discover other nodes in a ring-like structure as long as we don't // have more nodes to explore. for len(nextLevel) > 0 { From 5aacc251de208f7bd3cd02d93ec29d1eac456cfe Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 16 Jun 2022 10:13:33 +0200 Subject: [PATCH 2/2] docs: add release notes --- docs/release-notes/release-notes-0.15.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/release-notes-0.15.0.md b/docs/release-notes/release-notes-0.15.0.md index 89a44ceff..50dfde08c 100644 --- a/docs/release-notes/release-notes-0.15.0.md +++ b/docs/release-notes/release-notes-0.15.0.md @@ -185,6 +185,9 @@ from occurring that would result in an erroneous force close.](https://github.co * [Fixes a bug that would cause `SignPsbt` to panic w/ an underspecified packet](https://github.com/lightningnetwork/lnd/pull/6611) +* [Fixes a panic in the graph diameter calculation if the graph is + empty](https://github.com/lightningnetwork/lnd/pull/6647). + ## Routing * [Add a new `time_pref` parameter to the QueryRoutes and SendPayment APIs](https://github.com/lightningnetwork/lnd/pull/6024) that