From PDF specs (Syntax > File Structure > Cross reference table):
 The maximum generation number is 65,535; when a cross-reference entry reaches
 this value, it shall never be reused.

This patch adds a check for this condition.
From 5977c2436cd037829de91a8993630c982bfbc38c Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <[email protected]>
Date: Sat, 21 Apr 2012 21:08:55 +0200
Subject: [PATCH] Do not allocate XRef entries whose generation number is
 65535

---
 poppler/XRef.cc |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index e025107..ddb9ed3 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1199,7 +1199,10 @@ void XRef::setModifiedObject (Object* o, Ref r) {
 Ref XRef::addIndirectObject (Object* o) {
   int entryIndexToUse = -1;
   for (int i = 1; entryIndexToUse == -1 && i < size; ++i) {
-    if (getEntry(i)->type == xrefEntryFree) entryIndexToUse = i;
+    XRefEntry *e = getEntry(i);
+    if (e->type == xrefEntryFree && e->gen != 65535) {
+      entryIndexToUse = i;
+    }
   }
 
   XRefEntry *e;
-- 
1.7.6.5

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to