mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-02 03:48:24 +00:00
Tweak QPDF::getCompressibleObjGens
This commit is contained in:
parent
adb866efd3
commit
e28625144d
@ -2398,7 +2398,6 @@ QPDF::getCompressibleObjGens()
|
||||
|
||||
const size_t max_obj = getObjectCount();
|
||||
std::vector<bool> visited(max_obj, false);
|
||||
QPDFObjGen::set visited_gen; // for objects with generation > 0
|
||||
std::vector<QPDFObjectHandle> queue;
|
||||
queue.reserve(512);
|
||||
queue.push_back(m->trailer);
|
||||
@ -2409,19 +2408,25 @@ QPDF::getCompressibleObjGens()
|
||||
if (obj.isIndirect()) {
|
||||
QPDFObjGen og = obj.getObjGen();
|
||||
const size_t id = toS(og.getObj() - 1);
|
||||
const int gen = og.getGen();
|
||||
if (id >= max_obj)
|
||||
throw std::logic_error(
|
||||
"unexpected object id encountered in getCompressibleObjGens");
|
||||
if ((gen == 0 && visited[id]) || visited_gen.count(og)) {
|
||||
if (visited[id]) {
|
||||
QTC::TC("qpdf", "QPDF loop detected traversing objects");
|
||||
continue;
|
||||
}
|
||||
if (gen == 0) {
|
||||
visited[id] = true;
|
||||
} else {
|
||||
visited_gen.insert(og);
|
||||
|
||||
// Check whether this is the current object. If not, remove it (which changes it into a
|
||||
// direct null and therefore stops us from revisiting it) and move on to the next object
|
||||
// in the queue.
|
||||
auto upper = m->obj_cache.upper_bound(og);
|
||||
if (upper != m->obj_cache.end() && upper->first.getObj() == og.getObj()) {
|
||||
removeObject(og);
|
||||
continue;
|
||||
}
|
||||
|
||||
visited[id] = true;
|
||||
|
||||
if (og == encryption_dict_og) {
|
||||
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
|
||||
} else if (!(obj.isStream() ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user