Skip to content

garbage added with low (fast) compression levels #4

Closed
pstadt opened this Issue Sep 9, 2011 · 2 comments

3 participants

@pstadt
pstadt commented Sep 9, 2011

Looks like zip_deflate_internal checks for zip_match_available which is never initialized in case of (zip_compr_level <= 3).
This leads to additional bytes added to compressed data in case of deflate_fast. Some picky decompressors complain about it: optipng or firefox for example.

I fixed it this way:

--- rawdeflate.js.orig  2011-09-09 19:28:45.000000000 +0200
+++ rawdeflate.js       2011-09-09 19:25:14.000000000 +0200
@@ -753,6 +753,7 @@
     zip_qhead = null;
     zip_outcnt = 0;
     zip_outoff = 0;
+    zip_match_available = 0;
 
     if(zip_compr_level <= 3)
     {
@@ -762,7 +763,6 @@
     else
     {
        zip_match_length = zip_MIN_MATCH - 1;
-       zip_match_available = 0;
     }
 
     zip_complete = false;
@vlad-alexandru-ionescu

Thanks for your fix! This really saved my day over here.
Dankogai should have patched it.

@dankogai
Owner

Thank you. Patched accordingly.

@dankogai dankogai closed this Feb 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.