diff options
-rw-r--r-- | xps/xps_resource.c | 5 | ||||
-rw-r--r-- | xps/xps_tile.c | 11 | ||||
-rw-r--r-- | xps/xps_zip.c | 6 |
3 files changed, 17 insertions, 5 deletions
diff --git a/xps/xps_resource.c b/xps/xps_resource.c index fad60488..cfac562d 100644 --- a/xps/xps_resource.c +++ b/xps/xps_resource.c @@ -80,7 +80,8 @@ xps_parse_remote_resource_dictionary(xps_document *doc, char *base_uri, char *so s[1] = 0; dict = xps_parse_resource_dictionary(doc, part_uri, xml); - dict->base_xml = xml; /* pass on ownership */ + if (dict) + dict->base_xml = xml; /* pass on ownership */ return dict; } @@ -119,7 +120,7 @@ xps_parse_resource_dictionary(xps_document *doc, char *base_uri, xml_element *ro if (head) head->base_uri = fz_strdup(doc->ctx, base_uri); else - fz_throw(doc->ctx, "empty resource dictionary"); + fz_warn(doc->ctx, "empty resource dictionary"); return head; } diff --git a/xps/xps_tile.c b/xps/xps_tile.c index 04c613a4..1acdd369 100644 --- a/xps/xps_tile.c +++ b/xps/xps_tile.c @@ -269,11 +269,16 @@ xps_parse_canvas(xps_document *doc, fz_matrix ctm, fz_rect area, char *base_uri, for (node = xml_down(root); node; node = xml_next(node)) { + /* FIXME: Sumatra warns of memory leak here where we have multiple + * Canvas.Resources. */ if (!strcmp(xml_tag(node), "Canvas.Resources") && xml_down(node)) { new_dict = xps_parse_resource_dictionary(doc, base_uri, xml_down(node)); - new_dict->parent = dict; - dict = new_dict; + if (new_dict) + { + new_dict->parent = dict; + dict = new_dict; + } } if (!strcmp(xml_tag(node), "Canvas.RenderTransform")) @@ -341,6 +346,8 @@ xps_parse_fixed_page(xps_document *doc, fz_matrix ctm, xps_page *page) for (node = xml_down(page->root); node; node = xml_next(node)) { + /* FIXME: Sumatra warns of memory leak here where we have multiple + * FixedPage.Resources. */ if (!strcmp(xml_tag(node), "FixedPage.Resources") && xml_down(node)) dict = xps_parse_resource_dictionary(doc, base_uri, xml_down(node)); xps_parse_element(doc, ctm, area, base_uri, dict, node); diff --git a/xps/xps_zip.c b/xps/xps_zip.c index 7bc90319..04e37f4f 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -256,6 +256,7 @@ xps_read_zip_part(xps_document *doc, char *partname) xps_part *part; int count, size, offset, i; char *name; + int seen_last = 0; name = partname; if (name[0] == '/') @@ -273,7 +274,7 @@ xps_read_zip_part(xps_document *doc, char *partname) /* Count the number of pieces and their total size */ count = 0; size = 0; - while (1) + while (!seen_last) { sprintf(buf, "%s/[%d].piece", name, count); ent = xps_find_zip_entry(doc, buf); @@ -281,12 +282,15 @@ xps_read_zip_part(xps_document *doc, char *partname) { sprintf(buf, "%s/[%d].last.piece", name, count); ent = xps_find_zip_entry(doc, buf); + seen_last = (ent != NULL); } if (!ent) break; count ++; size += ent->usize; } + if (!seen_last) + fz_throw(doc->ctx, "cannot find all pieces for part '%s'", partname); /* Inflate the pieces */ if (count) |