From 45f1b92b72d5993d4568f31e1db903f9efd77291 Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Tue, 24 Feb 2026 03:37:46 -0500 Subject: [PATCH] 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 86b9245dd69b1ea7ba9a4f73fd3651808052ca6c) --- lib/pure/base64.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pure/base64.nim b/lib/pure/base64.nim index fd61119fa2..e18e9d3b4a 100644 --- a/lib/pure/base64.nim +++ b/lib/pure/base64.nim @@ -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)