lzw.pdf test case is broken
Commit 9107ffdf makes test/valid/lzw.pdf
report decoder failure. On commit 622e6a24, it produced an assertion failure:
$ ./pdf -v test/valid/lzw.pdf
assertion "code < ctx->next" failed: file "lzw.c", line 193, function "act_LZW_codeword"
Abort trap (core dumped)
$ gdb pdf pdf.core
...
(gdb) up 3
#3 0x00000cb7b5f72994 in act_LZW_codeword (p=0xcba78109678, u=0xcbaa5003000)
at lzw.c:193
193 assert(code < ctx->next);
Current language: auto; currently minimal
(gdb) print *ctx
$1 = {lzw_code_table = 0xcbaa5003000, next = 511, old = 32, earlychange = 1}
The file was derived from 000263.pdf
in the govdocs corpus, which produces the same assertion failure:
$ ./pdf -v govdocs-000263.pdf
decode_stream:: Unsupported Filter [DCTDecode]
parse error in stream (type XObject)
assertion "code < ctx->next" failed: file "lzw.c", line 193, function "act_LZW_codeword"
Abort trap (core dumped)
$ gdb pdf pdf.core
...
(gdb) up 3
#3 0x00000cba407ab994 in act_LZW_codeword (p=0xcbd0d2982d0, u=0xcbcefeb4000)
at lzw.c:193
193 assert(code < ctx->next);
Current language: auto; currently minimal
(gdb) print *ctx
$1 = {lzw_code_table = 0xcbcefeb4000, next = 511, old = 32, earlychange = 1}
It seems that both files are invalid somehow, or our code has a bug. I'd like to know which. Also, it would be nice to have a real-world LZW test case.