From e24215b47ad5cd6599973c3a76a375b99ad75d44 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Tue, 16 Apr 2019 15:13:18 +0200 Subject: Fix crash in stats for removed interfaces/nodes Change-Id: I36b4cd2625c7f0c5846fe402be7b2aeece4707f8 Signed-off-by: Ondrej Fabry --- core/stats.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core') diff --git a/core/stats.go b/core/stats.go index 4cbd9f2..48b516c 100644 --- a/core/stats.go +++ b/core/stats.go @@ -196,6 +196,9 @@ func (c *StatsConnection) GetNodeStats() (*api.NodeStats, error) { } } for i, v := range perNode { + if len(nodeStats.Nodes) <= i { + break + } nodeCounters := nodeStats.Nodes[i] fn(&nodeCounters, v) nodeStats.Nodes[i] = nodeCounters @@ -257,6 +260,9 @@ func (c *StatsConnection) GetInterfaceStats() (*api.InterfaceStats, error) { } } for i, v := range perIf { + if len(ifStats.Interfaces) <= i { + break + } ifCounters := ifStats.Interfaces[i] fn(&ifCounters, v) ifStats.Interfaces[i] = ifCounters -- cgit 1.2.3-korg