Fix a memory leak (#1305)

`font` was not freed upon error.
This commit is contained in:
Julien Voisin 2023-01-05 21:48:01 +01:00 committed by GitHub
parent 81b8747d80
commit 7133ea5419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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); 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(!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; goto failure;
}
font->space_advance = face->glyph->advance.x / 64.0f; font->space_advance = face->glyph->advance.x / 64.0f;
font->tab_advance = font->space_advance * 2; font->tab_advance = font->space_advance * 2;
return font; return font;