src/share/native/java/util/zip/Inflater.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -48,14 +48,19 @@
JNIEXPORT void JNICALL
Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls)
{
needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z");
+ CHECK_NULL(needDictID);
finishedID = (*env)->GetFieldID(env, cls, "finished", "Z");
+ CHECK_NULL(finishedID);
bufID = (*env)->GetFieldID(env, cls, "buf", "[B");
+ CHECK_NULL(bufID);
offID = (*env)->GetFieldID(env, cls, "off", "I");
+ CHECK_NULL(offID);
lenID = (*env)->GetFieldID(env, cls, "len", "I");
+ CHECK_NULL(lenID);
}
JNIEXPORT jlong JNICALL
Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
{
@@ -125,18 +130,18 @@
jbyte *out_buf;
int ret;
in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
if (in_buf == NULL) {
- if (this_len != 0)
+ if (this_len != 0 && (*env)->ExceptionOccurred(env) == NULL)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
if (out_buf == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
- if (len != 0)
+ if (len != 0 && (*env)->ExceptionOccurred(env) == NULL)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) (in_buf + this_off);
strm->next_out = (Bytef *) (out_buf + off);
@@ -152,11 +157,11 @@
/* 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 len - strm->avail_out;
+ return (jint) (len - strm->avail_out);
case Z_NEED_DICT:
(*env)->SetBooleanField(env, this, needDictID, JNI_TRUE);
/* Might have consumed some input here! */
this_off += this_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off);