From d8932772ef699093409f86d195dc853806f8d336 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 2 Jan 2017 23:48:13 +0000 Subject: [PATCH] Don't crash when trying to load a non-existent vector/bitmap character. --- src/resource.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/resource.cpp b/src/resource.cpp index 6f8102a..7d2dfc3 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -497,8 +497,10 @@ const BitmapFont::Glyph &BitmapFont::GetGlyph(char32_t codepoint) { mid--; } - // Read the codepoint. ASCIIReader reader = { mid, unifontData.cend() }; + if(reader.AtEnd()) break; + + // Read the codepoint. char32_t foundCodepoint = reader.Read16HexBits(); reader.ExpectChar(':'); @@ -724,8 +726,10 @@ const VectorFont::Glyph &VectorFont::GetGlyph(char32_t codepoint) { mid--; } - // Read the codepoint. ASCIIReader reader = { mid, lffData.cend() }; + if(reader.AtEnd()) break; + + // Read the codepoint. reader.ExpectChar('['); char32_t foundCodepoint = reader.Read16HexBits(); reader.ExpectChar(']');