]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/xpdf/Parser.cc
add tests for GPdfPersistFile.
[evince.git] / pdf / xpdf / Parser.cc
index 4df53c986caae7dfc98811eed10290957259324d..deb894aefb39591d427fb1921abaaee7fda1f871 100644 (file)
@@ -2,15 +2,16 @@
 //
 // Parser.cc
 //
-// Copyright 1996-2002 Glyph & Cog, LLC
+// Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
 
-#ifdef __GNUC__
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
 #pragma implementation
 #endif
 
-#include <aconf.h>
 #include <stddef.h>
 #include "Object.h"
 #include "Array.h"
@@ -88,8 +89,10 @@ Object *Parser::getObj(Object *obj) {
       } else {
        key = copyString(buf1.getName());
        shift();
-       if (buf1.isEOF() || buf1.isError())
+       if (buf1.isEOF() || buf1.isError()) {
+         gfree(key);
          break;
+       }
 #ifndef NO_DECRYPTION
        obj->dictAdd(key, getObj(&obj2, fileKey, keyLength, objNum, objGen));
 #else
@@ -200,7 +203,13 @@ Stream *Parser::makeStream(Object *dict) {
 
 void Parser::shift() {
   if (inlineImg > 0) {
-    ++inlineImg;
+    if (inlineImg < 2) {
+      ++inlineImg;
+    } else {
+      // in a damaged content stream, if 'ID' shows up in the middle
+      // of a dictionary, we need to reset
+      inlineImg = 0;
+    }
   } else if (buf2.isCmd("ID")) {
     lexer->skipChar();         // skip char after 'ID' command
     inlineImg = 1;