fix: double check inputIndex in base64.decode (#25531)

fixes https://github.com/nim-lang/Nim/issues/25530

this double checks the index to make sure whitespace related index
increments cannot cause index defect error
This commit is contained in:
Miroslav Shubernetskiy
2026-02-24 03:37:46 -05:00
committed by GitHub
parent e58acc2e1e
commit 86b9245dd6

View File

@@ -255,6 +255,9 @@ proc decode*(s: string): string =
while inputIndex <= inputEnds:
while s[inputIndex] in {'\n', '\r', ' '}:
inc inputIndex
# double check inputIndex as it can be incremented due to whitespace
if inputIndex > inputEnds:
break
inputChar(a)
inputChar(b)
inputChar(c)