summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-09-26 02:31:32 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-09-26 18:35:33 +0800
commitecc5c28eb0eb9801bf7c434c1483d6e3ab997075 (patch)
treeb2a29f01589cf12d247101f443a48355a1e44461 /source/html
parentdf6fca4d8306c06e262ae8ed88c90d7b0400dac5 (diff)
downloadmupdf-ecc5c28eb0eb9801bf7c434c1483d6e3ab997075.tar.xz
Fix memory leak when opening html/loading raw stream.
Diffstat (limited to 'source/html')
-rw-r--r--source/html/html-doc.c13
1 files changed, 10 insertions, 3 deletions
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;
}