< prev index next >

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

Print this page
rev 13912 : 8151848: Higher native memory usage caused by upgrade to zlib 1.2.8
Reviewed-by: sherman
Contributed-by: nikolay@azulsystems.com

*** 145,163 **** } strm->next_in = (Bytef *) (in_buf + this_off); strm->next_out = (Bytef *) (out_buf + off); strm->avail_in = this_len; strm->avail_out = len; ! ret = inflate(strm, Z_PARTIAL_FLUSH); (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0); (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); switch (ret) { case Z_STREAM_END: (*env)->SetBooleanField(env, this, finishedID, JNI_TRUE); /* fall through */ case Z_OK: this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); return (jint) (len - strm->avail_out); case Z_NEED_DICT: --- 145,170 ---- } strm->next_in = (Bytef *) (in_buf + this_off); strm->next_out = (Bytef *) (out_buf + off); strm->avail_in = this_len; strm->avail_out = len; ! ! /* 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); return (jint) (len - strm->avail_out); case Z_NEED_DICT:
*** 165,176 **** /* Might have consumed some input here! */ this_off += this_len - strm->avail_in; (*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; case Z_MEM_ERROR: JNU_ThrowOutOfMemoryError(env, 0); --- 172,181 ----
< prev index next >