Skip to content

Commit

Permalink
Fix a memory leak (lite-xl#1305)
Browse files Browse the repository at this point in the history
`font` was not freed upon error.
  • Loading branch information
jvoisin authored Jan 5, 2023
1 parent 81b8747 commit 7133ea5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ RenFont* ren_font_load(const char* path, float size, ERenFontAntialiasing antial
font->underline_thickness = (unsigned short)((face->underline_thickness / (float)face->units_per_EM) * font->size);
if(!font->underline_thickness) font->underline_thickness = ceil((double) font->height / 14.0);

if (FT_Load_Char(face, ' ', font_set_load_options(font)))
if (FT_Load_Char(face, ' ', font_set_load_options(font))) {
free(font);
goto failure;
}
font->space_advance = face->glyph->advance.x / 64.0f;
font->tab_advance = font->space_advance * 2;
return font;
Expand Down

0 comments on commit 7133ea5

Please sign in to comment.