summaryrefslogtreecommitdiff
path: root/source/xps/xps-resource.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-12-07 15:15:26 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-12-13 15:01:05 +0100
commiteacd070190d0c7a7fbc905a2a292f38e282b5a82 (patch)
tree57971ec5acec6b5867cc313c3d2f6f6f619e35fe /source/xps/xps-resource.c
parentfa9cd085533f68367c299e058ab3fbb7ad8a2dc6 (diff)
downloadmupdf-eacd070190d0c7a7fbc905a2a292f38e282b5a82.tar.xz
Parse XML using pool allocator.
This needs adding a fz_xml_doc type to hold the pool.
Diffstat (limited to 'source/xps/xps-resource.c')
-rw-r--r--source/xps/xps-resource.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/source/xps/xps-resource.c b/source/xps/xps-resource.c
index 8e81ab83..4a344902 100644
--- a/source/xps/xps-resource.c
+++ b/source/xps/xps-resource.c
@@ -59,48 +59,45 @@ xps_parse_remote_resource_dictionary(fz_context *ctx, xps_document *doc, char *b
{
char part_name[1024];
char part_uri[1024];
- xps_resource *dict;
xps_part *part;
- fz_xml *xml = NULL;
+ xps_resource *dict = NULL;
+ fz_xml_doc *xml = NULL;
char *s;
+ fz_var(xml);
+
/* External resource dictionaries MUST NOT reference other resource dictionaries */
xps_resolve_url(ctx, doc, part_name, base_uri, source_att, sizeof part_name);
+
part = xps_read_part(ctx, doc, part_name);
fz_try(ctx)
{
xml = fz_parse_xml(ctx, part->data, 0);
+ if (!fz_xml_is_tag(fz_xml_root(xml), "ResourceDictionary"))
+ fz_throw(ctx, FZ_ERROR_GENERIC, "expected ResourceDictionary element");
+
+ fz_strlcpy(part_uri, part_name, sizeof part_uri);
+ s = strrchr(part_uri, '/');
+ if (s)
+ s[1] = 0;
+
+ dict = xps_parse_resource_dictionary(ctx, doc, part_uri, fz_xml_root(xml));
+ if (dict)
+ {
+ dict->base_xml = xml; /* pass on ownership */
+ xml = NULL;
+ }
}
fz_always(ctx)
{
xps_drop_part(ctx, doc, part);
+ fz_drop_xml(ctx, xml);
}
fz_catch(ctx)
{
- fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
- xml = NULL;
+ fz_rethrow(ctx);
}
- if (!xml)
- return NULL;
-
- if (!fz_xml_is_tag(xml, "ResourceDictionary"))
- {
- fz_drop_xml(ctx, xml);
- fz_throw(ctx, FZ_ERROR_GENERIC, "expected ResourceDictionary element");
- }
-
- fz_strlcpy(part_uri, part_name, sizeof part_uri);
- s = strrchr(part_uri, '/');
- if (s)
- s[1] = 0;
-
- dict = xps_parse_resource_dictionary(ctx, doc, part_uri, xml);
- if (dict)
- dict->base_xml = xml; /* pass on ownership */
- else
- fz_drop_xml(ctx, xml);
-
return dict;
}