aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageObjectHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2021-03-04 21:47:51 +0100
committerJay Berkenbilt <ejb@ql.org>2021-03-04 21:59:45 +0100
commitf68e25c7f278bbfee095d43d4405a74df0bd22ff (patch)
tree6d6b18378c8438b927aa88264ba7ab3c02a7c758 /libqpdf/QPDFPageObjectHelper.cc
parentaa89476e155a25c4f44dc375885395a2734a547f (diff)
downloadqpdf-f68e25c7f278bbfee095d43d4405a74df0bd22ff.tar.zst
Don't use handleWarning, which is being reverted
Diffstat (limited to 'libqpdf/QPDFPageObjectHelper.cc')
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc20
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