From 3dbcbb8b2c8618f5f2f29548eba316dafc6d623c Mon Sep 17 00:00:00 2001 From: Ryan Flegel Date: Mon, 9 Jun 2008 02:06:05 +0000 Subject: [PATCH] #324: Hopefully this fixes the issue with malformed UTF-8 sequences causing SuperTux to crash SVN-Revision: 5546 --- src/video/font.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.11.0