poppler/XRef.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
New commits: commit 5f817cb2067a226bc7bc271a42e66bbbf2811d98 Author: Tobias Deiminger <[email protected]> Date: Mon Oct 1 21:39:06 2018 +0200 Skip XRef reconstruction for new-style XRef streams XRef::constructXRef was invented to support old style XRef tables. Sadly it won't work for XRef streams. If applied anyway, it corrupts our existing XRef::entries array. Better skip reconstruction for the XRef-stream-case in XRef::readXRefUntil (just like XRef::fetch already does). Fixes #139. diff --git a/poppler/XRef.cc b/poppler/XRef.cc index 3c124d8c..70fc2a22 100644 --- a/poppler/XRef.cc +++ b/poppler/XRef.cc @@ -809,6 +809,9 @@ GBool XRef::readXRefStreamSection(Stream *xrefStr, int *w, int first, int n) { } // Attempt to construct an xref table for a damaged file. +// Warning: Reconstruction of files where last XRef section is a stream +// or where some objects are defined inside an object stream is not yet supported. +// Existing data in XRef::entries may get corrupted if applied anyway. GBool XRef::constructXRef(GBool *wasReconstructed, GBool needCatalogDict) { Parser *parser; Object obj; @@ -1518,7 +1521,7 @@ void XRef::readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum) } if (followed) { error(errSyntaxError, -1, "Circular XRef"); - if (!(ok = constructXRef(nullptr))) { + if (!xRefStream && !(ok = constructXRef(nullptr))) { errCode = errDamaged; } break; @@ -1534,8 +1537,7 @@ void XRef::readXRefUntil(int untilEntryNum, std::vector<int> *xrefStreamObjsNum) // if there was a problem with the xref table, or we haven't found the entry // we were looking for, try to reconstruct the xref if (!ok || (!prevXRefOffset && untilEntryNum != -1 && entries[untilEntryNum].type == xrefEntryNone)) { - GBool wasReconstructed = false; - if (!(ok = constructXRef(&wasReconstructed))) { + if (!xRefStream && !(ok = constructXRef(nullptr))) { errCode = errDamaged; break; } @@ -1569,7 +1571,7 @@ XRefEntry *XRef::getEntry(int i, GBool complainIfMissing) if (entries[i].type == xrefEntryNone) { if (complainIfMissing) { - error(errSyntaxError, -1, "Invalid XRef entry"); + error(errSyntaxError, -1, "Invalid XRef entry {0:d}", i); } entries[i].type = xrefEntryFree; } _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
