From 940818d801ad8121ff8613a2b848bd9302a02286 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 22 Aug 2024 14:37:23 +0200 Subject: [PATCH] Do not do iterator underflow in urlDecode `value.end() - 3` may be "before start of string" if string length is < 3. On Windows debug, is throw an exception. On other platform it is probably an undefined behavior. Rewrite the test to avoid such invalid substraction. --- src/tools/stringTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/stringTools.cpp b/src/tools/stringTools.cpp index 690fcd65c..05ed6a198 100644 --- a/src/tools/stringTools.cpp +++ b/src/tools/stringTools.cpp @@ -257,7 +257,7 @@ std::string kiwix::urlDecode(const std::string& value, bool component) // If there aren't enough characters left for this to be a // valid escape code, just use the character and move on - if (it > value.end() - 3) { + if (value.end() - it < 3) { os << *it; continue; }