From 06139693c613084e2029bd1406d1ced57a97a1d5 Mon Sep 17 00:00:00 2001 From: nxshock Date: Fri, 13 Jan 2023 22:18:02 +0500 Subject: [PATCH] Prevent out of bounds when access to empty comma parameter --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 0989349..b9593c6 100644 --- a/main.go +++ b/main.go @@ -135,7 +135,7 @@ func processReader(c *cli.Context, r io.Reader) error { reader.TrimLeadingSpace = false reader.FieldsPerRecord = len(c.String("fields")) - if []rune(c.String("comma"))[0] == 't' { + if runes := []rune(c.String("comma")); len(runes) > 0 && runes[0] == 't' { reader.Comma = '\t' } else { reader.Comma = []rune(c.String("comma"))[0]