[poppler] poppler/XRef.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Dec 16 18:08:43 UTC 2020
poppler/XRef.cc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
New commits:
commit 407293bfb9108c9d9e2611a294b389ed9c593900
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Dec 16 10:21:31 2020 +0100
Fix potential data loss if we try to fetch a non existing Ref after modifying the document
diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index 2cfe2136..66d3f04a 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1208,6 +1208,20 @@ Object XRef::fetch(int num, int gen, int recursion, Goffset *endPos)
err:
if (!xRefStream && !xrefReconstructed) {
+ // Check if there has been any updated object, if there has been we can't reconstruct because that would mean losing the changes
+ bool xrefHasChanges = false;
+ for (int i = 0; !xrefHasChanges && i < size; i++) {
+ if (entries[i].getFlag(XRefEntry::Updated)) {
+ xrefHasChanges = true;
+ }
+ }
+ if (xrefHasChanges) {
+ error(errInternal, -1, "xref num {0:d} not found but needed, document has changes, reconstruct aborted\n", num);
+ // pretend we constructed the xref, otherwise we will do this check again and again
+ xrefReconstructed = true;
+ return Object(objNull);
+ }
+
error(errInternal, -1, "xref num {0:d} not found but needed, try to reconstruct\n", num);
rootNum = -1;
constructXRef(&xrefReconstructed);
More information about the poppler
mailing list