Prevent out of bounds when access to empty comma parameter

This commit is contained in:
nxshock 2023-01-13 22:18:02 +05:00
parent c4f18766cb
commit 06139693c6

View File

@ -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]