X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FParser.cc;h=0aa66d32ef0cdf33b18b25c9955d2e948bfd3eab;hb=25a9ea784b39a717a6b0f27ab4a8c21d9b3afc82;hp=4bcb0ceb87d30f846bd842ab5a3e56537f226544;hpb=64676031423465996e83c4a685290f0c3d97a249;p=evince.git diff --git a/pdf/xpdf/Parser.cc b/pdf/xpdf/Parser.cc index 4bcb0ceb..0aa66d32 100644 --- a/pdf/xpdf/Parser.cc +++ b/pdf/xpdf/Parser.cc @@ -2,7 +2,7 @@ // // Parser.cc // -// Copyright 1996-2002 Glyph & Cog, LLC +// Copyright 1996-2003 Glyph & Cog, LLC // //======================================================================== @@ -176,10 +176,16 @@ Stream *Parser::makeStream(Object *dict) { } // check for length in damaged file - if (xref->getStreamEnd(pos, &endPos)) { + if (xref && xref->getStreamEnd(pos, &endPos)) { length = endPos - pos; } + // in badly damaged PDF files, we can run off the end of the input + // stream immediately after the "stream" token + if (!lexer->getStream()) { + return NULL; + } + // make base stream str = lexer->getStream()->getBaseStream()->makeSubStream(pos, gTrue, length, dict); @@ -193,10 +199,12 @@ Stream *Parser::makeStream(Object *dict) { // refill token buffers and check for 'endstream' shift(); // kill '>>' shift(); // kill 'stream' - if (buf1.isCmd("endstream")) + if (buf1.isCmd("endstream")) { shift(); - else + } else { error(getPos(), "Missing 'endstream'"); + str->ignoreLength(); + } return str; }