Fix memory leak in font.c

This commit is contained in:
simon987 2020-03-06 09:35:19 -05:00
parent 7ceb645926
commit cfdd7bdd87
2 changed files with 8 additions and 0 deletions

View File

@ -140,6 +140,7 @@ void parse_font(const char *buf, size_t buf_len, document_t *doc) {
if (ft_lib == NULL) {
FT_Init_FreeType(&ft_lib);
}
if (buf == NULL) {
return;
}
@ -169,6 +170,7 @@ void parse_font(const char *buf, size_t buf_len, document_t *doc) {
APPEND_META(doc, meta_name)
if (ScanCtx.tn_size <= 0) {
FT_Done_Face(face);
return;
}
@ -178,6 +180,7 @@ void parse_font(const char *buf, size_t buf_len, document_t *doc) {
err = FT_Set_Pixel_Sizes(face, 0, pixel);
if (err != 0) {
LOG_WARNINGF(doc->filepath, "(font.c) FT_Set_Pixel_Sizes() returned error code [%d] %s", err, ft_error_string(err))
FT_Done_Face(face);
return;
}
@ -224,3 +227,7 @@ void parse_font(const char *buf, size_t buf_len, document_t *doc) {
FT_Done_Face(face);
}
void cleanup_font() {
FT_Done_FreeType(ft_lib);
}

View File

@ -5,5 +5,6 @@
void parse_font(const char * buf, size_t buf_len, document_t *doc);
void cleanup_font();
#endif