From 63c8290faf4cec2c25a7ae4addde38ad2e5817f9 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 7 Jan 2016 13:37:48 +0100 Subject: epub: Fix memory leaks. --- source/html/html-layout.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source/html/html-layout.c') diff --git a/source/html/html-layout.c b/source/html/html-layout.c index b22dd106..f9c34bc3 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -217,8 +217,8 @@ static void generate_text(fz_context *ctx, fz_pool *pool, fz_html *box, const ch static void generate_image(fz_context *ctx, fz_pool *pool, fz_archive *zip, const char *base_uri, fz_html *box, const char *src) { - fz_image *img; - fz_buffer *buf; + fz_image *img = NULL; + fz_buffer *buf = NULL; char path[2048]; fz_html *flow = box; @@ -231,14 +231,20 @@ static void generate_image(fz_context *ctx, fz_pool *pool, fz_archive *zip, cons fz_urldecode(path); fz_cleanname(path); + fz_var(buf); + fz_var(img); + fz_try(ctx) { buf = fz_read_archive_entry(ctx, zip, path); img = fz_new_image_from_buffer(ctx, buf); - fz_drop_buffer(ctx, buf); - add_flow_image(ctx, pool, flow, &box->style, img); } + fz_always(ctx) + { + fz_drop_buffer(ctx, buf); + fz_drop_image(ctx, img); + } fz_catch(ctx) { const char *alt = "[image]"; -- cgit v1.2.3