summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-10-02 13:21:00 +0800
committerTor Andersson <tor.andersson@artifex.com>2018-10-23 18:46:01 +0200
commitc3bcc9db6ac5e2e88061c5f9ed72e1aeb5750a32 (patch)
tree485a4328f59d306862ad9cf1e60c7d879b1171ef /source
parent9dffe5b5b9dbb6ecd003c6daa539bdb0705e48f0 (diff)
downloadmupdf-c3bcc9db6ac5e2e88061c5f9ed72e1aeb5750a32.tar.xz
Drop SVG document upon exception opening directory.
Diffstat (limited to 'source')
-rw-r--r--source/svg/svg-doc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/svg/svg-doc.c b/source/svg/svg-doc.c
index b06410da..f2ea5a10 100644
--- a/source/svg/svg-doc.c
+++ b/source/svg/svg-doc.c
@@ -83,19 +83,24 @@ static fz_document *
svg_open_document_with_buffer(fz_context *ctx, fz_buffer *buf)
{
svg_document *doc;
- fz_xml_doc *xml;
-
- xml = fz_parse_xml(ctx, buf, 0);
doc = fz_new_derived_document(ctx, svg_document);
doc->super.drop_document = svg_drop_document;
doc->super.count_pages = svg_count_pages;
doc->super.load_page = svg_load_page;
- doc->xml = xml;
doc->idmap = NULL;
- svg_build_id_map(ctx, doc, fz_xml_root(xml));
+ fz_try(ctx)
+ {
+ doc->xml = fz_parse_xml(ctx, buf, 0);
+ svg_build_id_map(ctx, doc, fz_xml_root(doc->xml));
+ }
+ fz_catch(ctx)
+ {
+ fz_drop_document(ctx, &doc->super);
+ fz_rethrow(ctx);
+ }
return (fz_document*)doc;
}