diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-12-08 21:06:20 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-12-08 21:46:56 +0100 |
commit | 6796e89abefe67ea1e35e5f40f6a77620b6de9d8 (patch) | |
tree | 77635bafb33e939501de66e27cd393aafbc75b0b /xps/xps_outline.c | |
parent | 787c07bc94c3aa163981cb0321e92ce465d33d5f (diff) | |
download | mupdf-6796e89abefe67ea1e35e5f40f6a77620b6de9d8.tar.xz |
Throw exceptions in xps code.
Diffstat (limited to 'xps/xps_outline.c')
-rw-r--r-- | xps/xps_outline.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/xps/xps_outline.c b/xps/xps_outline.c index 48eb100b..ae43a4e8 100644 --- a/xps/xps_outline.c +++ b/xps/xps_outline.c @@ -83,23 +83,29 @@ xps_load_document_structure(xps_document *doc, xps_fixdoc *fixdoc) fz_outline *outline; part = xps_read_part(doc, fixdoc->outline); - if (!part) - return NULL; - - root = xml_parse_document(doc->ctx, part->data, part->size); - if (!root) { - fz_error_handle(-1, "cannot parse document structure part '%s'", part->name); + fz_try(doc->ctx) + { + root = xml_parse_document(doc->ctx, part->data, part->size); + } + fz_catch(doc->ctx) + { xps_free_part(doc, part); - return NULL; + fz_rethrow(doc->ctx); } + xps_free_part(doc, part); - outline = xps_parse_document_structure(doc, root); - + fz_try(doc->ctx) + { + outline = xps_parse_document_structure(doc, root); + } + fz_catch(doc->ctx) + { + xml_free_element(doc->ctx, root); + fz_rethrow(doc->ctx); + } xml_free_element(doc->ctx, root); - xps_free_part(doc, part); return outline; - } fz_outline * @@ -111,13 +117,11 @@ xps_load_outline(xps_document *doc) for (fixdoc = doc->first_fixdoc; fixdoc; fixdoc = fixdoc->next) { if (fixdoc->outline) { outline = xps_load_document_structure(doc, fixdoc); - if (outline) { - if (!head) - head = outline; - else - tail->next = outline; - tail = outline; - } + if (!head) + head = outline; + else + tail->next = outline; + tail = outline; } } return head; |