lzham_codec icon indicating copy to clipboard operation
lzham_codec copied to clipboard

lzham_lib_z_deflateInit2 writes zlib header/footer even if negative window_bits passed

Open AndrewSav opened this issue 8 years ago • 0 comments

In lzham_lib_z_deflateInit2 function of lzham_lzcomp.cpp there is following code:

 if (method == LZHAM_Z_DEFLATED)
      {
         // Force Deflate to LZHAM with default window_bits.
         method = LZHAM_Z_LZHAM;
         window_bits = LZHAM_Z_DEFAULT_WINDOW_BITS;
      }

A little bit down below we see this:

 if (window_bits > 0)
         comp_params.m_compress_flags |= LZHAM_COMP_FLAG_WRITE_ZLIB_STREAM;

This means that if you pass deflate as methods and -15 as window_bits as you would with zlib and expect it not to write zlib header/adler-32 footer you will be disappointed. The first piece of code will change -15 to 15, and then the second piece of code happily will add the header/footer flag.

Is this intentional?

AndrewSav avatar Sep 15 '15 10:09 AndrewSav