From ba7af78cfa6a926bf055811fc9be0cad8737cb41 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 17 Dec 2017 17:04:48 +0000 Subject: [PATCH] ensure result adjacencies start empty Any existing list would be mutated by result(), which is bad. Note that all the existing newJoinResults() call sites pass in nodes with no adjacencies, so this is purely a safety measure. --- render/render.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/render/render.go b/render/render.go index 72b3f8d30..b54115f42 100644 --- a/render/render.go +++ b/render/render.go @@ -169,6 +169,7 @@ type joinResults struct { func newJoinResults(inputNodes report.Nodes) joinResults { nodes := make(report.Nodes, len(inputNodes)) for id, n := range inputNodes { + n.Adjacency = nil // result() assumes all nodes start with no adjacencies nodes[id] = n } return joinResults{nodes: nodes, mapped: map[string]string{}} @@ -206,7 +207,7 @@ func (ret *joinResults) addChildAndChildren(m report.Node, id string, create fun // Add a copy of n straight into the results func (ret *joinResults) passThrough(n report.Node) { - n.Adjacency = nil // result() assumes all nodes start with blank lists + n.Adjacency = nil // result() assumes all nodes start with no adjacencies ret.nodes[n.ID] = n ret.mapped[n.ID] = n.ID }