Bug 1895872 - Avoid generating a broken PDF when a link destination is not present in the generated output. r=gfx-reviewers,jrmuizel

Fix confirmed by ajohnson (see comment 8) to work around the reported issue.

Differential Revision: https://phabricator.services.mozilla.com/D210024
This commit is contained in:
Jonathan Kew 2024-05-10 13:12:44 +00:00
parent ed9da08589
commit 5925d49da5
2 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,21 @@
# HG changeset patch
# User Jonathan Kew <jkew@mozilla.com>
# Date 1715329864 -3600
# Fri May 10 09:31:04 2024 +0100
# Node ID 0e12f0bc1e445c0afb23e620aa0321ccf7d7c4a8
# Parent 8f49349eeb0ec5df0e1dd3ddd98423138921a029
Bug 1895872 - Avoid generating a broken PDF when a link destination is missing. r=#gfx-reviewers
diff --git a/gfx/cairo/cairo/src/cairo-pdf-interchange.c b/gfx/cairo/cairo/src/cairo-pdf-interchange.c
--- a/gfx/cairo/cairo/src/cairo-pdf-interchange.c
+++ b/gfx/cairo/cairo/src/cairo-pdf-interchange.c
@@ -1506,7 +1506,8 @@ cairo_pdf_interchange_write_forward_link
TRUE,
x, y);
} else {
- return _cairo_tag_error ("Link to dest=\"%s\" not found", link->dest);
+ // Destination is missing: just give the link an empty dest string.
+ _cairo_output_stream_printf(surface->object_stream.stream, "<>\n");
}
} else {
cairo_pdf_interchange_write_explicit_dest (surface,

View File

@ -1506,7 +1506,8 @@ cairo_pdf_interchange_write_forward_links (cairo_pdf_surface_t *surface)
TRUE,
x, y);
} else {
return _cairo_tag_error ("Link to dest=\"%s\" not found", link->dest);
// Destination is missing: just give the link an empty dest string.
_cairo_output_stream_printf(surface->object_stream.stream, "<>\n");
}
} else {
cairo_pdf_interchange_write_explicit_dest (surface,