Skip to content

Commit 074a675

Browse files
committed
Out of range panic fix
The Svace static analyzer (https://www.ispras.ru/en/technologies/svace/) flagged this code as suspicious: it could lead to a panic (out of range) if len(out) == 0. It might happen if text would be "bla:bla"
1 parent 53e9e67 commit 074a675

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crypto.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ func parseCrypto(r io.Reader) ([]Crypto, error) {
8686
if len(kv) != 2 {
8787
return nil, fmt.Errorf("%w: Cannot parse line: %q", ErrFileParse, text)
8888
}
89-
89+
if len(out) == 0 {
90+
continue
91+
}
9092
k := strings.TrimSpace(kv[0])
9193
v := strings.TrimSpace(kv[1])
9294

0 commit comments

Comments
 (0)