summaryrefslogtreecommitdiff
path: root/source/html
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-01 13:04:25 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-10-09 13:18:47 +0800
commitd34d3b123fa404e57c6b64d89a61a8f28c05ae5b (patch)
tree0ec42f2a9b5d5f85f33c036090f32a26fbde0cfb /source/html
parent2255281844adfebbab86374f10c9c4ab203c453c (diff)
downloadmupdf-d34d3b123fa404e57c6b64d89a61a8f28c05ae5b.tar.xz
html: Fix leak of buffer when opening as 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 3567723e..fdd087dc 100644
--- a/source/html/html-doc.c
+++ b/source/html/html-doc.c
@@ -165,9 +165,16 @@ htdoc_open_document(fz_context *ctx, const char *filename)
doc->set = fz_new_html_font_set(ctx);
buf = fz_read_file(ctx, filename);
- 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;
}