2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-22 22:58:33 +00:00

Fix errors in --remove-unreferenced-resources=auto

This commit is contained in:
Jay Berkenbilt 2020-04-06 12:14:27 -04:00
parent 1e629c278a
commit 892937cbbe
2 changed files with 4 additions and 2 deletions

View File

@ -4846,13 +4846,13 @@ static bool should_remove_unreferenced_resources(QPDF& pdf, Options& o)
while (! queue.empty()) while (! queue.empty())
{ {
QPDFObjectHandle node = *queue.begin(); QPDFObjectHandle node = *queue.begin();
queue.pop_front();
QPDFObjGen og = node.getObjGen(); QPDFObjGen og = node.getObjGen();
if (nodes_seen.count(og)) if (nodes_seen.count(og))
{ {
continue; continue;
} }
nodes_seen.insert(og); nodes_seen.insert(og);
queue.pop_front();
QPDFObjectHandle dict = node.isStream() ? node.getDict() : node; QPDFObjectHandle dict = node.isStream() ? node.getDict() : node;
QPDFObjectHandle kids = dict.getKey("/Kids"); QPDFObjectHandle kids = dict.getKey("/Kids");
if (kids.isArray()) if (kids.isArray())
@ -4898,7 +4898,9 @@ static bool should_remove_unreferenced_resources(QPDF& pdf, Options& o)
} }
resources_seen.insert(resources_og); resources_seen.insert(resources_og);
} }
QPDFObjectHandle xobject = resources.getKey("/XObject"); QPDFObjectHandle xobject = (resources.isDictionary() ?
resources.getKey("/XObject") :
QPDFObjectHandle::newNull());
if (xobject.isIndirect()) if (xobject.isIndirect())
{ {
QPDFObjGen xobject_og = xobject.getObjGen(); QPDFObjGen xobject_og = xobject.getObjGen();