diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFPageObjectHelper.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index ba647372..c5ede04f 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -99,11 +99,16 @@ QPDFPageObjectHelper::addContentTokenFilter( class NameWatcher: public QPDFObjectHandle::TokenFilter { public: + NameWatcher() : + saw_bad(false) + { + } virtual ~NameWatcher() { } virtual void handleToken(QPDFTokenizer::Token const&); std::set<std::string> names; + bool saw_bad; }; void @@ -116,6 +121,10 @@ NameWatcher::handleToken(QPDFTokenizer::Token const& token) this->names.insert( QPDFObjectHandle::newName(token.getValue()).getName()); } + else if (token.getType() == QPDFTokenizer::tt_bad) + { + saw_bad = true; + } writeToken(token); } @@ -134,6 +143,14 @@ QPDFPageObjectHelper::removeUnreferencedResources() "; not attempting to remove unreferenced objects from this page"); return; } + if (nw.saw_bad) + { + QTC::TC("qpdf", "QPDFPageObjectHelper bad token finding names"); + this->oh.warnIfPossible( + "Bad token found while scanning content stream; " + "not attempting to remove unreferenced objects from this page"); + return; + } // Walk through /Font and /XObject dictionaries, removing any // resources that are not referenced. We must make copies of // resource dictionaries down into the dictionaries are mutating |