e211c25f06
When the parser finds a stream, it retrieves the Length from the stream dictionary and advances the lexer to the offset as specified in Length. If this Length is incorrect, the lexer could end up anywhere. When the lexer gets in an invalid state, it could throw errors. For example, in issue 6108, the lexer ends up inside the stream data. This stream has the ASCIIHexDecode filter, so all characters are made up from ASCII characters, and the lexer interprets it as a command token. Tokens cannot be longer than 127 bytes, so eventually 128 bytes are consumed and the lexer throws "Command token too long" error. Another possible error is "Illegal character: 41" when the lexer happens to end up at a ')' due to the length mismatch. These problems are solved by catching lexer errors and recovering the parser via the existing stream length detection branch.
680 B
680 B