From ecc5c28eb0eb9801bf7c434c1483d6e3ab997075 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Mon, 26 Sep 2016 02:31:32 +0800 Subject: Fix memory leak when opening html/loading raw stream. --- source/html/html-doc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/html') diff --git a/source/html/html-doc.c b/source/html/html-doc.c index f14ddc35..733dd620 100644 --- a/source/html/html-doc.c +++ b/source/html/html-doc.c @@ -129,9 +129,16 @@ htdoc_open_document_with_stream(fz_context *ctx, fz_stream *file) doc->set = fz_new_html_font_set(ctx); buf = fz_read_all(ctx, file, 0); - fz_write_buffer_byte(ctx, buf, 0); - doc->box = fz_parse_html(ctx, doc->set, doc->zip, ".", buf, fz_user_css(ctx)); - fz_drop_buffer(ctx, buf); + + fz_try(ctx) + { + fz_write_buffer_byte(ctx, buf, 0); + doc->box = fz_parse_html(ctx, doc->set, doc->zip, ".", buf, fz_user_css(ctx)); + } + fz_always(ctx) + fz_drop_buffer(ctx, buf); + fz_catch(ctx) + fz_rethrow(ctx); return (fz_document*)doc; } -- cgit v1.2.3