From 658af50006670bcdf03f34243b5ba9c2a01b8cc3 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Tue, 1 Sep 2020 23:57:40 +0300 Subject: [PATCH] do not crash with corrupted history entries Related #455 --- app.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.go b/app.go index 0633375..d33d065 100644 --- a/app.go +++ b/app.go @@ -95,6 +95,12 @@ func (app *app) readHistory() error { scanner := bufio.NewScanner(f) for scanner.Scan() { toks := strings.SplitN(scanner.Text(), " ", 2) + if toks[0] != ":" && toks[0] != "$" && toks[0] != "%" && toks[0] != "!" && toks[0] != "&" { + continue + } + if len(toks) < 2 { + continue + } app.cmdHistory = append(app.cmdHistory, cmdItem{toks[0], toks[1]}) }