Bug 692033 - LZWEncode filter sometimes outputs 1 byte too many
Summary: LZWEncode filter sometimes outputs 1 byte too many
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 9.00
Hardware: PC Windows XP
: P2 major
Assignee: Alex Cherepanov
URL:
Keywords:
: 692307 692386 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-07 22:38 UTC by Paul Tribick
Modified: 2011-09-04 01:13 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
Postscript program that creates the error (see stdout) (21.34 KB, application/postscript)
2011-03-07 22:38 UTC, Paul Tribick
Details
patch (607 bytes, patch)
2011-09-03 04:55 UTC, Alex Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Tribick 2011-03-07 22:38:49 UTC
Created attachment 7334 [details]
Postscript program that creates the error (see stdout)

Under some circumstances LZWEncode produces one too many bytes and the resultant string causes an ioerror when decoded. See attached program example.
Comment 1 Paul Tribick 2011-03-07 22:46:57 UTC
Apologies...

The attached program shortens the encoded sting by one byte to show that the sting can be decoded by Ghostscript.

The line:

/lzw lzw_encode_buffer 0 img# 1 sub getinterval def	% the LZW encoded string

should read:

/lzw lzw_encode_buffer 0 img# getinterval def	% the LZW encoded string

to demonstrate the ioerror in Ghostscript.

P.
Comment 2 Ken Sharp 2011-06-30 08:16:57 UTC
*** Bug 692307 has been marked as a duplicate of this bug. ***
Comment 3 Ken Sharp 2011-06-30 08:19:44 UTC
See Bug #692307. Its not clear that the problem with the LZWEncode filter is as simple as producing an extra byte. The bitmap encoded in the 's' glyph in the output of ps2write causes an ioerror when run through other rips, but it is not cured by removing one byte of data.

Raising the prioirity of this as ps2write makes extensive use of teh LZWEncode filter, and we really need this to work correctly. This may also now be a customer issue.
Comment 4 Alex Cherepanov 2011-09-03 04:55:37 UTC
Created attachment 7866 [details]
patch

I think, the code size should be incremented writing the last code
but I cannot find a good description of LZW algorithm.

The description in the TIFF manual is the best I found but it is too
informal.
Comment 5 Alex Cherepanov 2011-09-04 01:11:01 UTC
The patch has been committed as a rev.
42582272f2b4dce1ccd5c600a2d6dc71794b4d3e
Comment 6 Alex Cherepanov 2011-09-04 01:13:53 UTC
*** Bug 692386 has been marked as a duplicate of this bug. ***