From 76ade4c3b4712c6ca9bf3a93c4c97563763e150d Mon Sep 17 00:00:00 2001 From: kota kanbe Date: Wed, 6 Apr 2016 12:09:29 +0900 Subject: [PATCH] Fix panic: runtime error: index out of range in tui mode #5 --- report/tui.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/report/tui.go b/report/tui.go index c836f2a5..6f8bc595 100644 --- a/report/tui.go +++ b/report/tui.go @@ -602,7 +602,6 @@ func summaryLines(data models.ScanResult) string { } stable.AddRow(icols...) } - // ignore UnknownCves return fmt.Sprintf("%s", stable) } @@ -625,7 +624,6 @@ func setDetailLayout(g *gocui.Gui) error { // currentScanResult.KnownCves[currentCveInfo], // currentScanResult.Family) - //TODO error handling text, err := detailLines() if err != nil { return err @@ -654,6 +652,10 @@ type dataForTmpl struct { } func detailLines() (string, error) { + if len(currentScanResult.KnownCves) == 0 { + return "No vulnerable packages", nil + } + cveInfo := currentScanResult.KnownCves[currentCveInfo] cveID := cveInfo.CveDetail.CveID