Skip to content

Commit

Permalink
Don't crash when trying to load a non-existent vector/bitmap character.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Jan 2, 2017
1 parent 02ab358 commit d893277
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(':');

Expand Down Expand Up @@ -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(']');
Expand Down

0 comments on commit d893277

Please sign in to comment.