24-pdf-interchange-mcid-crash.patch (1639B)
1 diff --git a/gfx/cairo/cairo/src/cairo-pdf-interchange.c b/gfx/cairo/cairo/src/cairo-pdf-interchange.c 2 index 6bda9e8b813ba9f222dc10d83e3e7d0c4293bb79..0e910fd227be2d0904f8bd8c7b19a350afdf7ef3 100644 3 --- a/gfx/cairo/cairo/src/cairo-pdf-interchange.c 4 +++ b/gfx/cairo/cairo/src/cairo-pdf-interchange.c 5 @@ -1991,14 +1991,22 @@ _cairo_pdf_interchange_command_id (cairo_pdf_surface_t *surface, 6 if (surface->paginated_mode == CAIRO_PAGINATED_MODE_RENDER && ic->current_render_node) { 7 /* TODO If the group does not have tags we don't need to close the current tag. */ 8 if (command_list_is_group (surface, command_id)) { 9 + /* A "Do /xnnn" can not be inside a tag (since the 10 + * XObject may also contain tags). Close the tag. 11 + */ 12 if (ic->marked_content_open) { 13 status = _cairo_pdf_operators_tag_end (&surface->pdf_operators); 14 ic->marked_content_open = FALSE; 15 } 16 - if (command_list_has_content (surface, command_id, NULL)) { 17 + /* If there is any more content after this and we are 18 + * inside a tag (current node is not the root node), 19 + * ensure that the next command will open the tag. 20 + */ 21 + if (command_list_has_content (surface, command_id, NULL) && ic->current_render_node->parent) { 22 ic->render_next_command_has_content = TRUE; 23 } 24 } else if (ic->render_next_command_has_content) { 25 + /* After a "Do /xnnn" operation, if there is more content, open the tag. */ 26 add_mcid_to_node (surface, ic->current_render_node, ic->command_id, &mcid); 27 status = _cairo_pdf_operators_tag_begin (&surface->pdf_operators, 28 ic->current_render_node->name, mcid);