mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Improve getCompressibleObjGens fix to handle gen > 0
This commit is contained in:
parent
ba477e0b33
commit
df61f3a6c6
@ -2378,6 +2378,7 @@ QPDF::getCompressibleObjGens()
|
|||||||
|
|
||||||
const size_t max_obj = getObjectCount();
|
const size_t max_obj = getObjectCount();
|
||||||
std::vector<bool> visited(max_obj, false);
|
std::vector<bool> visited(max_obj, false);
|
||||||
|
QPDFObjGen::set visited_gen; // for objects with generation > 0
|
||||||
std::vector<QPDFObjectHandle> queue;
|
std::vector<QPDFObjectHandle> queue;
|
||||||
queue.reserve(512);
|
queue.reserve(512);
|
||||||
queue.push_back(m->trailer);
|
queue.push_back(m->trailer);
|
||||||
@ -2388,14 +2389,19 @@ QPDF::getCompressibleObjGens()
|
|||||||
if (obj.isIndirect()) {
|
if (obj.isIndirect()) {
|
||||||
QPDFObjGen og = obj.getObjGen();
|
QPDFObjGen og = obj.getObjGen();
|
||||||
const size_t id = toS(og.getObj() - 1);
|
const size_t id = toS(og.getObj() - 1);
|
||||||
|
const int gen = og.getGen();
|
||||||
if (id >= max_obj)
|
if (id >= max_obj)
|
||||||
throw std::runtime_error(
|
throw std::logic_error(
|
||||||
"unexpected object id encountered in getCompressibleObjGens");
|
"unexpected object id encountered in getCompressibleObjGens");
|
||||||
if (visited[id]) {
|
if ((gen == 0 && visited[id]) || visited_gen.count(og)) {
|
||||||
QTC::TC("qpdf", "QPDF loop detected traversing objects");
|
QTC::TC("qpdf", "QPDF loop detected traversing objects");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
visited[id] = true;
|
if (gen == 0) {
|
||||||
|
visited[id] = true;
|
||||||
|
} else {
|
||||||
|
visited_gen.insert(og);
|
||||||
|
}
|
||||||
if (og == encryption_dict_og) {
|
if (og == encryption_dict_og) {
|
||||||
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
|
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
|
||||||
} else if (!(obj.isStream() ||
|
} else if (!(obj.isStream() ||
|
||||||
|
Loading…
Reference in New Issue
Block a user