Fix infinite loop when a symbol name in an invalid object file starts with an invalid UTF-8 byte like 0xC0

This commit is contained in:
Rangi
2026-08-22 18:06:32 -04:00
parent 71d9e236bc
commit ed0a2d1075
+1 -2
View File
@@ -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