araskind / jmzml

Automatically exported from code.google.com/p/jmzml
0 stars 0 forks source link

Zlib compression broken for 16 byte data. #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The compress method appears to be assuming that the maxiumum size of zlib 
compressed data will be the size of the source data, however when you have very 
small data size, the compressed size can be bigger, e.g. different 16 byte data 
compressed to 22 and 24 bytes.

When this happens, the compressed data is truncated into the 16 byte array. The 
number of compressed bytes is reported as the size of the destination byte 
array supplied to the deflater.

When decompression is later called, the first decompression iteration 
decompresses 14 bytes of the original 16 bytes. Then the execution hangs 
indefinitely on inflater.isFinished which will never return true as the data 
can never be fully decompressed as data is missing.

This could be fixed by allocating a bigger byte array for the compressed data 
when doing to the original compression.

Original issue reported on code.google.com by simon.ri...@googlemail.com on 5 Dec 2013 at 1:18