src/share/native/java/util/zip/Deflater.c
Print this page
@@ -136,17 +136,19 @@
int level = (*env)->GetIntField(env, this, levelID);
int strategy = (*env)->GetIntField(env, this, strategyID);
in_buf = (jbyte *) malloc(this_len);
if (in_buf == 0) {
+ JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
out_buf = (jbyte *) malloc(len);
if (out_buf == 0) {
free(in_buf);
+ JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) in_buf;
strm->next_out = (Bytef *) out_buf;
@@ -177,17 +179,19 @@
} else {
jboolean finish = (*env)->GetBooleanField(env, this, finishID);
in_buf = (jbyte *) malloc(this_len);
if (in_buf == 0) {
+ JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
out_buf = (jbyte *) malloc(len);
if (out_buf == 0) {
free(in_buf);
+ JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) in_buf;
strm->next_out = (Bytef *) out_buf;