From ed0a2d107598d6c4bfba90614c2977a856f00b09 Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 22 Aug 2026 18:06:32 -0400 Subject: [PATCH] Fix infinite loop when a symbol name in an invalid object file starts with an invalid UTF-8 byte like 0xC0 --- src/link/output.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/link/output.cpp b/src/link/output.cpp index aca09b44..4eb60ef6 100644 --- a/src/link/output.cpp +++ b/src/link/output.cpp @@ -279,8 +279,7 @@ static void writeSymName(std::string const &name, FILE *file) { // Decode the UTF-8 codepoint; or at least attempt to Utf8Decoder decoder; do { - if (decoder.update(*ptr) != UTF8_REJECT) { - ++ptr; + if (decoder.update(*ptr++) != UTF8_REJECT) { continue; } // This sequence was invalid; emit a U+FFFD, and recover