diff options
Diffstat (limited to 'pdf/xpdf/Parser.cc')
-rw-r--r-- | pdf/xpdf/Parser.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/pdf/xpdf/Parser.cc b/pdf/xpdf/Parser.cc index 4df53c9..4bcb0ce 100644 --- a/pdf/xpdf/Parser.cc +++ b/pdf/xpdf/Parser.cc @@ -6,11 +6,12 @@ // //======================================================================== -#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; |