diff options
author | Simon Bünzli <zeniko@gmail.com> | 2013-11-11 22:36:40 +0100 |
---|---|---|
committer | Simon Bünzli <zeniko@gmail.com> | 2013-11-27 20:43:51 +0100 |
commit | 827a710ffda3a28a302f22233e45e18697bbfa26 (patch) | |
tree | c128d841514c32e31fee912fc382d47c7c7a07d5 /source | |
parent | a290828ad27a30b894e7bc11f77b612e8cec83a8 (diff) | |
download | mupdf-827a710ffda3a28a302f22233e45e18697bbfa26.tar.xz |
fix memory leak introduced with a2c945506ea2a2b58edbde84124094c6b4f69eac
fz_new_font_from_buffer keeps the buffer for the font, so callers which
no longer need the data have to drop the buffer themselves explicitly.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-font.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 638b5b35..0d387151 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -204,6 +204,7 @@ pdf_load_substitute_font(fz_context *ctx, pdf_font_desc *fontdesc, char *fontnam if (buffer) { fontdesc->font = fz_new_font_from_buffer(ctx, fontname, buffer, 0, 1); + fz_drop_buffer(ctx, buffer); } else { @@ -304,9 +305,12 @@ pdf_load_embedded_font(pdf_document *doc, pdf_font_desc *fontdesc, char *fontnam { fontdesc->font = fz_new_font_from_buffer(ctx, fontname, buf, 0, 1); } - fz_catch(ctx) + fz_always(ctx) { fz_drop_buffer(ctx, buf); + } + fz_catch(ctx) + { fz_rethrow_message(ctx, "cannot load embedded font (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref)); } fontdesc->size += buf->len; |