-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Nim Version
2.2.6
Description
(example using fish shell)
➜ nim c -r (echo '
import base64
echo decode(" a")
' | psub -s '.nim')
/tmp/.psub.PVFMMD/psub.nim(3) psub
/home/root/.choosenim/toolchains/nim-2.2.6/lib/pure/base64.nim(230) decode
/home/root/.choosenim/toolchains/nim-2.2.6/lib/system/fatal.nim(53) sysFatal
Error: unhandled exception: index 4 not in 0 .. 3 [IndexDefect]if a string to be decoded is prefixed with whitespace due to:
Lines 252 to 259 in ab00c56
| inputEnds = inputLen - 4 | |
| while inputIndex <= inputEnds: | |
| while s[inputIndex] in {'\n', '\r', ' '}: | |
| inc inputIndex | |
| inputChar(a) | |
| inputChar(b) | |
| inputChar(c) | |
| inputChar(d) |
as it increments inputIndex it can increment it outside of the outer loop bound inputLen - 4 hence inputChar blows up with out of bounds error
Current Output
`IndexDefect` is raised
Expected Output
base64 should decode as normal
Known Workarounds
call strip before using decode:
decode(s.strip())Additional Information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels