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

(cherry picked from commit 86b9245dd6)
This commit is contained in:
Miroslav Shubernetskiy
2026-02-24 03:37:46 -05:00
committed by narimiran
parent 5ec6391124
commit 45f1b92b72

View File

@@ -253,6 +253,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)