diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-03-11 18:49:27 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-03-11 18:49:27 +0100 |
commit | 972e08af58838f5494a05f70683d848130755d78 (patch) | |
tree | b9445138db806110a57eeaa5fb373963d73c39c2 | |
parent | 85884c363c21b90c025326d84428a23be024b1c9 (diff) | |
download | qpdf-972e08af58838f5494a05f70683d848130755d78.tar.zst |
Protect against future bugs in fixCopiedAnnotations
I don't want additional, undiscovered bugs to fully block page
splitting/merging operations.
-rw-r--r-- | qpdf/qpdf.cc | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc index 48467734..f51e0454 100644 --- a/qpdf/qpdf.cc +++ b/qpdf/qpdf.cc @@ -5946,9 +5946,20 @@ static void handle_page_specs(QPDF& pdf, Options& o, bool& warnings) { QTC::TC("qpdf", "qpdf copy fields non-first from orig"); } - this_afdh->fixCopiedAnnotations( - new_page, to_copy.getObjectHandle(), *other_afdh, - &referenced_fields); + try + { + this_afdh->fixCopiedAnnotations( + new_page, to_copy.getObjectHandle(), *other_afdh, + &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()) @@ -6400,7 +6411,18 @@ static void do_split_pages(QPDF& pdf, Options& o, bool& warnings) if (out_afdh.getPointer()) { QTC::TC("qpdf", "qpdf copy form fields in split_pages"); - out_afdh->fixCopiedAnnotations(new_page, page, afdh); + try + { + 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()) |