From c3d9f08d70530ff83c8e08a664614d85d162efb4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 19 Jul 2016 14:30:40 +0100 Subject: Fix memory leak in fz_new_buffer_from_image_as_png. --- source/fitz/output-png.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/fitz') diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c index d710a0cd..11696980 100644 --- a/source/fitz/output-png.c +++ b/source/fitz/output-png.c @@ -287,7 +287,18 @@ png_from_pixmap(fz_context *ctx, fz_pixmap *pix, int drop) fz_buffer * fz_new_buffer_from_image_as_png(fz_context *ctx, fz_image *image) { - return png_from_pixmap(ctx, fz_get_pixmap_from_image(ctx, image, NULL, NULL, NULL, NULL), 0); + fz_pixmap *pix = fz_get_pixmap_from_image(ctx, image, NULL, NULL, NULL, NULL); + fz_buffer *buf = NULL; + + fz_var(buf); + + fz_try(ctx) + buf = png_from_pixmap(ctx, pix, 0); + fz_always(ctx) + fz_drop_pixmap(ctx, pix); + fz_catch(ctx) + fz_rethrow(ctx); + return buf; } fz_buffer * -- cgit v1.2.3