From: Ryan Flegel Date: Mon, 9 Jun 2008 02:06:05 +0000 (+0000) Subject: #324: Hopefully this fixes the issue with malformed UTF-8 sequences causing SuperTux... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=3dbcbb8b2c8618f5f2f29548eba316dafc6d623c;p=supertux.git #324: Hopefully this fixes the issue with malformed UTF-8 sequences causing SuperTux to crash SVN-Revision: 5546 --- diff --git a/src/video/font.cpp b/src/video/font.cpp index 50949b207..e0f56648b 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -49,7 +49,12 @@ struct UTF8Iterator : text(text_), pos(0) { - chr = decode_utf8(text, pos); + try { + chr = decode_utf8(text, pos); + } catch (std::exception) { + log_debug << "Malformed utf-8 sequence beginning with " << *((uint32_t*)(text.c_str() + pos)) << " found " << std::endl; + chr = 0; + } } bool done() const @@ -60,7 +65,7 @@ struct UTF8Iterator UTF8Iterator& operator++() { try { chr = decode_utf8(text, pos); - } catch (std::runtime_error) { + } catch (std::exception) { log_debug << "Malformed utf-8 sequence beginning with " << *((uint32_t*)(text.c_str() + pos)) << " found " << std::endl; chr = 0; ++pos;