mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
fix problem with lzw decoder when run without early code change, now that we actually have test input
git-svn-id: svn+q:///qpdf/trunk@646 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
9f93c89ee5
commit
da7166bead
@ -1,3 +1,10 @@
|
|||||||
|
2009-02-19 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* libqpdf/Pl_LZWDecoder.cc: correct logic error for previously
|
||||||
|
untested case of running the LZW decoder without the "early code
|
||||||
|
change" flag. Thanks to a bug report from "Atom Smasher", I
|
||||||
|
finally was able to obtain an input stream compressed in this way.
|
||||||
|
|
||||||
2009-02-15 Jay Berkenbilt <ejb@ql.org>
|
2009-02-15 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* 2.0.3: release
|
* 2.0.3: release
|
||||||
|
@ -199,7 +199,7 @@ Pl_LZWDecoder::handleCode(int code)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned int last_idx = 258 + table_size;
|
unsigned int last_idx = 258 + table_size;
|
||||||
if (last_idx == 4095)
|
if (last_idx + code_change_delta == 4096)
|
||||||
{
|
{
|
||||||
throw QEXC::General("LZWDecoder: table full");
|
throw QEXC::General("LZWDecoder: table full");
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,18 @@
|
|||||||
#include <qpdf/Pl_StdioFile.hh>
|
#include <qpdf/Pl_StdioFile.hh>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main()
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
bool early_code_change = true;
|
||||||
|
if ((argc == 2) && (strcmp(argv[1], "--no-early-code-change") == 0))
|
||||||
|
{
|
||||||
|
early_code_change = false;
|
||||||
|
}
|
||||||
|
|
||||||
Pl_StdioFile out("stdout", stdout);
|
Pl_StdioFile out("stdout", stdout);
|
||||||
// We don't exercise LZWDecoder with early code change false
|
Pl_LZWDecoder decode("decode", &out, early_code_change);
|
||||||
// because we have no way to generate such an LZW stream.
|
|
||||||
Pl_LZWDecoder decode("decode", &out, true);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,31 @@ require TestDriver;
|
|||||||
|
|
||||||
my $td = new TestDriver('lzw');
|
my $td = new TestDriver('lzw');
|
||||||
|
|
||||||
$td->runtest("decode",
|
cleanup();
|
||||||
{$td->COMMAND => "lzw < lzw1.in"},
|
|
||||||
{$td->FILE => "lzw1.out",
|
$td->runtest("decode: early code change",
|
||||||
|
{$td->COMMAND => "lzw < lzw1.in > tmp"},
|
||||||
|
{$td->STRING => "",
|
||||||
$td->EXIT_STATUS => 0});
|
$td->EXIT_STATUS => 0});
|
||||||
|
|
||||||
$td->report(1);
|
$td->runtest("check output",
|
||||||
|
{$td->FILE => "tmp"},
|
||||||
|
{$td->FILE => "lzw1.out"});
|
||||||
|
|
||||||
|
$td->runtest("decode: no early code change",
|
||||||
|
{$td->COMMAND => "lzw --no-early-code-change < lzw2.in > tmp"},
|
||||||
|
{$td->STRING => "",
|
||||||
|
$td->EXIT_STATUS => 0});
|
||||||
|
|
||||||
|
$td->runtest("check output",
|
||||||
|
{$td->FILE => "tmp"},
|
||||||
|
{$td->FILE => "lzw2.out"});
|
||||||
|
|
||||||
|
cleanup();
|
||||||
|
|
||||||
|
$td->report(4);
|
||||||
|
|
||||||
|
sub cleanup
|
||||||
|
{
|
||||||
|
unlink "tmp";
|
||||||
|
}
|
||||||
|
BIN
libtests/qtest/lzw/lzw2.in
Normal file
BIN
libtests/qtest/lzw/lzw2.in
Normal file
Binary file not shown.
BIN
libtests/qtest/lzw/lzw2.out
Normal file
BIN
libtests/qtest/lzw/lzw2.out
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user