--- old/src/share/native/java/util/zip/Inflater.c 2015-10-21 19:32:53.394976400 +0400 +++ new/src/share/native/java/util/zip/Inflater.c 2015-10-21 19:32:52.938214800 +0400 @@ -142,15 +142,22 @@ strm->next_out = (Bytef *) (out_buf + off); strm->avail_in = this_len; strm->avail_out = len; - ret = inflate(strm, Z_PARTIAL_FLUSH); + + /* The flush parameter of inflate() is set to Z_FINISH to skip + the allocation of a sliding window until necessary. */ + ret = inflate(strm, Z_FINISH); (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0); (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); + /* When flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it + will return Z_BUF_ERROR if it has not reached the end of the stream. + Here we keep the same processing for both these return codes. */ switch (ret) { case Z_STREAM_END: (*env)->SetBooleanField(env, this, finishedID, JNI_TRUE); /* fall through */ case Z_OK: + case Z_BUF_ERROR: this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); @@ -162,8 +169,6 @@ (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); return 0; - case Z_BUF_ERROR: - return 0; case Z_DATA_ERROR: ThrowDataFormatException(env, strm->msg); return 0;