diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2012-01-12 01:29:06 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-01-12 01:29:06 +0100 |
commit | 413ec18a295a1fb140c18c2cf7a275d7f2ff9735 (patch) | |
tree | 1a6ff3934d1ba9289c350b30b46db7971f9dc2b5 | |
parent | 9994b3f49db7bd925a7ae7874cbc99025469ee9e (diff) | |
download | mupdf-413ec18a295a1fb140c18c2cf7a275d7f2ff9735.tar.xz |
Fix memory leak in font->bbox_table.
-rw-r--r-- | fitz/res_font.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/fitz/res_font.c b/fitz/res_font.c index a851e3c7..84291fe7 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -6,7 +6,7 @@ #define MAX_BBOX_TABLE_SIZE 4096 -static void fz_finalize_freetype(fz_context *ctx); +static void fz_drop_freetype(fz_context *ctx); static fz_font * fz_new_font(fz_context *ctx, char *name, int use_glyph_bbox, int glyph_count) @@ -97,17 +97,13 @@ fz_drop_font(fz_context *ctx, fz_font *font) fterr = FT_Done_Face((FT_Face)font->ft_face); if (fterr) fz_warn(ctx, "freetype finalizing face: %s", ft_error_string(fterr)); - fz_finalize_freetype(ctx); + fz_drop_freetype(ctx); } - if (font->ft_file) - fz_free(ctx, font->ft_file); - if (font->ft_data) - fz_free(ctx, font->ft_data); - - if (font->width_table) - fz_free(ctx, font->width_table); - + fz_free(ctx, font->ft_file); + fz_free(ctx, font->ft_data); + fz_free(ctx, font->bbox_table); + fz_free(ctx, font->width_table); fz_free(ctx, font); } } @@ -174,7 +170,7 @@ char *ft_error_string(int err) } static void -fz_init_freetype(fz_context *ctx) +fz_keep_freetype(fz_context *ctx) { int fterr; int maj, min, pat; @@ -203,7 +199,7 @@ fz_init_freetype(fz_context *ctx) } static void -fz_finalize_freetype(fz_context *ctx) +fz_drop_freetype(fz_context *ctx) { int fterr; fz_font_context *fct = ctx->font; @@ -224,12 +220,12 @@ fz_new_font_from_file(fz_context *ctx, char *path, int index, int use_glyph_bbox fz_font *font; int fterr; - fz_init_freetype(ctx); + fz_keep_freetype(ctx); fterr = FT_New_Face(ctx->font->ftlib, path, index, &face); if (fterr) { - fz_finalize_freetype(ctx); + fz_drop_freetype(ctx); fz_throw(ctx, "freetype: cannot load font: %s", ft_error_string(fterr)); } @@ -250,12 +246,12 @@ fz_new_font_from_memory(fz_context *ctx, unsigned char *data, int len, int index fz_font *font; int fterr; - fz_init_freetype(ctx); + fz_keep_freetype(ctx); fterr = FT_New_Memory_Face(ctx->font->ftlib, data, len, index, &face); if (fterr) { - fz_finalize_freetype(ctx); + fz_drop_freetype(ctx); fz_throw(ctx, "freetype: cannot load font: %s", ft_error_string(fterr)); } |