[poppler] poppler/Parser.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Sat Sep 26 05:58:53 PDT 2009


 poppler/Parser.cc |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

New commits:
commit 074dc5e5e39cebc1fbe9bf6a15b2cae2391006c1
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sat Sep 26 14:56:38 2009 +0200

    Improve realibility for Streams with broken Length
    
    Fixes bug 6841

diff --git a/poppler/Parser.cc b/poppler/Parser.cc
index bc19ea9..b531233 100644
--- a/poppler/Parser.cc
+++ b/poppler/Parser.cc
@@ -13,7 +13,7 @@
 // All changes made under the Poppler project to this file are licensed
 // under GPL version 2 or later
 //
-// Copyright (C) 2006 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2009 Albert Astals Cid <aacid at kde.org>
 // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk at gmail.com>
 //
 // To see a description of the changes please see the Changelog file that
@@ -209,9 +209,18 @@ Stream *Parser::makeStream(Object *dict, Guchar *fileKey,
     shift();
   } else {
     error(getPos(), "Missing 'endstream'");
-    // kludge for broken PDF files: just add 5k to the length, and
-    // hope its enough
-    length += 5000;
+    if (xref) {
+      // shift until we find the proper endstream or we change to another object or reach eof
+      while (!buf1.isCmd("endstream") && xref->getNumEntry(lexer->getPos()) == objNum && !buf1.isEOF()) {
+        shift();
+      }
+      length = lexer->getPos() - pos;
+    } else {
+      // When building the xref we can't use it so use this
+      // kludge for broken PDF files: just add 5k to the length, and
+      // hope its enough
+      length += 5000;
+    }
   }
 
   // make base stream


More information about the poppler mailing list