Empty values in inline mapping result in error
Closed this issue · 0 comments
ericcornelissen commented
Bug Report
- wordrow version:
v0.5.0-beta
- Operating system: Ubuntu 19.04
Description
Providing an incorrect mapping from the CLI (i.e. with a empty string on either side of the mapping) results in a crash.
Actual Behaviour
A program crash.
Expected Behaviour
The mapping is not used and the program potentially halts with an error message.
Working Example
Use the program with a CLI specified mapping such as --map "foo,"
or --map ",bar"
.
Log Output
$ wordrow --map "foo," inputfile.txt
panic: 1
goroutine 1 [running]:
github.com/ericcornelissen/wordrow/internal/wordmaps.(*WordMap).AddOne(0xc0000b7d78, 0x7ffc0fad0cbf, 0x3, 0x7ffc0fad0cbf, 0x0)
/media/win/workspace/wordrow/internal/wordmaps/wordmap.go:49 +0x230
main.processInlineMapping(0x7ffc0fad0cbf, 0x4, 0xc0000b7d78, 0x1, 0x1)
/media/win/workspace/wordrow/cmd/wordrow/wordmap.go:98 +0x189
main.processInlineMappings(0xc00005e3b0, 0x1, 0x1, 0xc0000b7d78, 0x0, 0x0)
/media/win/workspace/wordrow/cmd/wordrow/wordmap.go:108 +0xe8
main.getWordMap(0x0, 0x0, 0x0, 0xc00005e3b0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
/media/win/workspace/wordrow/cmd/wordrow/wordmap.go:128 +0xba
main.run(0x0, 0x0, 0x0, 0xc00005e3c0, 0x1, 0x1, 0x0, 0x0, 0x0, 0xc00005e3b0, ...)
/media/win/workspace/wordrow/cmd/wordrow/main.go:12 +0x81
main.main()
/media/win/workspace/wordrow/cmd/wordrow/main.go:51 +0xf7