summaryrefslogtreecommitdiff
path: root/source/xps/xps-resource.c
diff options
context:
space:
mode:
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;
}