From 0a178ce6cbb3e78daba3efe73eb5d8bdd8b27f75 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 3 Jan 2013 15:27:36 +1030 Subject: [PATCH] Parser: return error if stream encountered when allowStreams = false Opening a PDF file where the first object is a stream prints a "Command token too long" error message. This is caused by the Linearization check in Linearization::Linearization reading objects with allowStreams = false. The Parser ignores the "stream" token and tries reading the next token which is usually binary data. Setting allowStreams to true will not work since the stream length is often an indirect object and at this point the XRef has not been created. Fix this by making Parser return an error object if the "stream" token is encountered when allowStreams is false. Bug 58966 --- poppler/Parser.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/poppler/Parser.cc b/poppler/Parser.cc index 5b80293..431a279 100644 --- a/poppler/Parser.cc +++ b/poppler/Parser.cc @@ -125,14 +125,14 @@ Object *Parser::getObj(Object *obj, GBool simpleOnly, } // stream objects are not allowed inside content streams or // object streams - if (allowStreams && buf2.isCmd("stream")) { - if ((str = makeStream(obj, fileKey, encAlgorithm, keyLength, - objNum, objGen, recursion + 1, - strict))) { - obj->initStream(str); + if (buf2.isCmd("stream")) { + if (allowStreams && (str = makeStream(obj, fileKey, encAlgorithm, keyLength, + objNum, objGen, recursion + 1, + strict))) { + obj->initStream(str); } else { - obj->free(); - obj->initError(); + obj->free(); + obj->initError(); } } else { shift(); -- 1.7.10.4