diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-01-06 11:56:46 +0000 |
---|---|---|
committer | Robin Watts <robin@ghostscript.com> | 2012-01-06 13:49:24 +0000 |
commit | 8c0b958c8cd04eae8a65803db700240123fd38be (patch) | |
tree | 96c330707d07b24c6095b421e5a2ddb0d413348b /fitz | |
parent | 09f1a3d3d863099c103100ed10c8cec82ea7aed3 (diff) | |
download | mupdf-8c0b958c8cd04eae8a65803db700240123fd38be.tar.xz |
Various memory leak fixes.
In error cases, ensure we free objects correctly. Thanks to Zeniko
for finding the problems (and many of the solutions!)
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/filt_jbig2d.c | 2 | ||||
-rw-r--r-- | fitz/res_font.c | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/fitz/filt_jbig2d.c b/fitz/filt_jbig2d.c index 2d2e2eb9..3afcbcb0 100644 --- a/fitz/filt_jbig2d.c +++ b/fitz/filt_jbig2d.c @@ -112,10 +112,12 @@ fz_open_jbig2d(fz_stream *chain, fz_buffer *globals) if (state->ctx) jbig2_ctx_free(state->ctx); } + fz_drop_buffer(ctx, globals); fz_free(ctx, state); fz_close(chain); fz_rethrow(ctx); } + fz_drop_buffer(ctx, globals); return fz_new_stream(ctx, state, read_jbig2d, close_jbig2d); } diff --git a/fitz/res_font.c b/fitz/res_font.c index 38d6fdf1..053b2a04 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -209,7 +209,10 @@ fz_new_font_from_file(fz_context *ctx, char *path, int index) fterr = FT_New_Face(ctx->font->ftlib, path, index, &face); if (fterr) + { + fz_finalize_freetype(ctx); fz_throw(ctx, "freetype: cannot load font: %s", ft_error_string(fterr)); + } font = fz_new_font(ctx, face->family_name); font->ft_face = face; @@ -232,7 +235,10 @@ fz_new_font_from_memory(fz_context *ctx, unsigned char *data, int len, int index fterr = FT_New_Memory_Face(ctx->font->ftlib, data, len, index, &face); if (fterr) + { + fz_finalize_freetype(ctx); fz_throw(ctx, "freetype: cannot load font: %s", ft_error_string(fterr)); + } font = fz_new_font(ctx, face->family_name); font->ft_face = face; |