From c22a1bb82c4081544a8731ea3b327988389eac1a Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 27 Nov 2014 19:41:17 +0000 Subject: [PATCH] Handle invalid UTF-8 bytes without infinite loop --- renderdoc/serialise/utf8printf.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/renderdoc/serialise/utf8printf.cpp b/renderdoc/serialise/utf8printf.cpp index b8fdc0fbe..056d2f650 100644 --- a/renderdoc/serialise/utf8printf.cpp +++ b/renderdoc/serialise/utf8printf.cpp @@ -923,6 +923,13 @@ void formatargument(char type, void *rawarg, FormatterParams formatter, char *&o // skip past continuation bytes (if we hit a NULL terminator this loop will break out) while((*si & 0xC0) == 0x80) si++; } + else + { + // invalid UTF-8 byte to encounter, bail out here. + clipoffs = 0; + len = 0; + s = ""; + } len++; // one more codepoint if(len == precision && formatter.Precision != FormatterParams::NoPrecision)