From 057838478c923933cd5f352f25b186b2f7789100 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Thu, 16 Feb 2023 12:50:34 -0500 Subject: [PATCH] Fix overflow bug (#3) --- cmd/envcheckctl/exec_inspect.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/envcheckctl/exec_inspect.go b/cmd/envcheckctl/exec_inspect.go index ed27549..873b595 100644 --- a/cmd/envcheckctl/exec_inspect.go +++ b/cmd/envcheckctl/exec_inspect.go @@ -107,6 +107,9 @@ func PrintTop(n int, header string, c cluster.Counter) { return li[i].value > li[j].value }) log.Println(header) + if n > len(li) { + n = len(li) + } for _, v := range li[:n] { log.Printf("- \"%v\"=%d", v.name, v.value) }