operasoftware/jsunzip — Issue #1: Stream with distance reference over 1024 doesn't decompress correctly
Author: quicklyfrozen
Created: 2012-01-26 19:50:10+00:00
State: open

The issue is that some distance codes need more then 8 extra distance bits, and the existing read_bits function didn't handle that case (it only appears to allow for extracting 8 bits). I changed the line that parses out the value to:

val = d.tag & (0xffff >> (16 - num));

and it seems to be decoding my stream correctly.

I am using this to decode a live stream so I don't have sample data readily available to submit with this report, although I could try to generate some.

BTW, I appreciate the readability of this code vs. most other deflate implementations that I looked at.