diff options
Diffstat (limited to 'libqpdf/QPDFPageObjectHelper.cc')
-rw-r--r-- | libqpdf/QPDFPageObjectHelper.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index 43c4eef6..7f7e6bea 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -684,24 +684,28 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper( ResourceFinder rf; try { + auto q = ph.oh.getOwningQPDF(); + size_t before_nw = (q ? q->numWarnings() : 0); ph.parseContents(&rf); + size_t after_nw = (q ? q->numWarnings() : 0); + if (after_nw > before_nw) + { + ph.oh.warnIfPossible( + "Bad token found while scanning content stream; " + "not attempting to remove unreferenced objects from" + " this object"); + return false; + } } catch (std::exception& e) { + QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names"); ph.oh.warnIfPossible( std::string("Unable to parse content stream: ") + e.what() + "; not attempting to remove unreferenced objects" " from this object"); return false; } - if (rf.sawBad()) - { - QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names"); - ph.oh.warnIfPossible( - "Bad token found while scanning content stream; " - "not attempting to remove unreferenced objects from this object"); - return false; - } // We will walk through /Font and /XObject dictionaries, removing // any resources that are not referenced. We must make copies of |