src/java.base/share/native/libzip/Deflater.c

Print this page

        

@@ -74,11 +74,11 @@
 
     if (strm == 0) {
         JNU_ThrowOutOfMemoryError(env, 0);
         return jlong_zero;
     } else {
-        char *msg;
+        char *msg = 0;
         switch (deflateInit2(strm, level, Z_DEFLATED,
                              nowrap ? -MAX_WBITS : MAX_WBITS,
                              DEF_MEM_LEVEL, strategy)) {
           case Z_OK:
             return ptr_to_jlong(strm);

@@ -88,12 +88,17 @@
             return jlong_zero;
           case Z_STREAM_ERROR:
             free(strm);
             JNU_ThrowIllegalArgumentException(env, 0);
             return jlong_zero;
+          case Z_VERSION_ERROR:
+            msg = "Incompatible zlib version";
+            /* intentionally no break */
           default:
+            if (msg == 0) {
             msg = strm->msg;
+            }
             free(strm);
             JNU_ThrowInternalError(env, msg);
             return jlong_zero;
         }
     }