Skip to content

Commit

Permalink
Verify Font file before loading to gracefully fail instead of segfaul…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
NoelFB committed Oct 6, 2023
1 parent 70dfb1b commit 7f96d7f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Platform/src/foster_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ bool FosterGetFocused()

FosterFont* FosterFontInit(unsigned char* data, int length)
{
if (stbtt_GetNumberOfFonts(data) <= 0)
{
FosterLogError("Unable to parse Font File");
return NULL;
}

stbtt_fontinfo* info = (stbtt_fontinfo*)SDL_malloc(sizeof(stbtt_fontinfo));

if (stbtt_InitFont(info, data, 0) == 0)
Expand Down

0 comments on commit 7f96d7f

Please sign in to comment.