From b62da66ba970b95b61dfac4764efceb8f569d731 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 29 Dec 2023 22:59:35 +0000 Subject: [PATCH] Fix #11644: Off by one error in StrMakeValid UTF-8 decode overrun detection --- src/string.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/string.cpp b/src/string.cpp index 020fd2fd47..5ec8453480 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -141,7 +141,7 @@ static void StrMakeValid(T &dst, const char *str, const char *last, StringValida * would also reach the "last" byte of the string and a normal '\0' * termination will be placed after it. */ - if (len == 0 || str + len > last || len != Utf8Decode(&c, str)) { + if (len == 0 || str + len > last + 1 || len != Utf8Decode(&c, str)) { /* Maybe the next byte is still a valid character? */ str++; continue;