2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-12-23 03:18:59 +00:00

Protect against future bugs in fixCopiedAnnotations

I don't want additional, undiscovered bugs to fully block page
splitting/merging operations.
This commit is contained in:
Jay Berkenbilt 2021-03-11 12:49:27 -05:00
parent 85884c363c
commit 972e08af58

View File

@ -5946,10 +5946,21 @@ static void handle_page_specs(QPDF& pdf, Options& o, bool& warnings)
{ {
QTC::TC("qpdf", "qpdf copy fields non-first from orig"); QTC::TC("qpdf", "qpdf copy fields non-first from orig");
} }
try
{
this_afdh->fixCopiedAnnotations( this_afdh->fixCopiedAnnotations(
new_page, to_copy.getObjectHandle(), *other_afdh, new_page, to_copy.getObjectHandle(), *other_afdh,
&referenced_fields); &referenced_fields);
} }
catch (std::exception& e)
{
pdf.warn(
QPDFExc(qpdf_e_damaged_pdf, pdf.getFilename(),
"", 0, "Exception caught while fixing copied"
" annotations. This may be a qpdf bug." +
std::string("Exception: ") + e.what()));
}
}
} }
if (page_data.qpdf->anyWarnings()) if (page_data.qpdf->anyWarnings())
{ {
@ -6400,8 +6411,19 @@ static void do_split_pages(QPDF& pdf, Options& o, bool& warnings)
if (out_afdh.getPointer()) if (out_afdh.getPointer())
{ {
QTC::TC("qpdf", "qpdf copy form fields in split_pages"); QTC::TC("qpdf", "qpdf copy form fields in split_pages");
try
{
out_afdh->fixCopiedAnnotations(new_page, page, afdh); out_afdh->fixCopiedAnnotations(new_page, page, afdh);
} }
catch (std::exception& e)
{
pdf.warn(
QPDFExc(qpdf_e_damaged_pdf, pdf.getFilename(),
"", 0, "Exception caught while fixing copied"
" annotations. This may be a qpdf bug." +
std::string("Exception: ") + e.what()));
}
}
} }
if (pldh.hasPageLabels()) if (pldh.hasPageLabels())
{ {