--- old/src/share/native/java/util/zip/Deflater.c 2009-07-08 16:41:02.000000000 +0200 +++ new/src/share/native/java/util/zip/Deflater.c 2009-07-08 16:41:02.000000000 +0200 @@ -137,14 +137,14 @@ int strategy = (*env)->GetIntField(env, this, strategyID); in_buf = (jbyte *) malloc(this_len); - if (in_buf == 0) { + if (in_buf == 0 && this_len > 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) { + if (out_buf == 0 && len > 0) { free(in_buf); JNU_ThrowOutOfMemoryError(env, 0); return 0; @@ -180,14 +180,14 @@ jboolean finish = (*env)->GetBooleanField(env, this, finishID); in_buf = (jbyte *) malloc(this_len); - if (in_buf == 0) { + if (in_buf == 0 && this_len > 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) { + if (out_buf == 0 && len > 0) { free(in_buf); JNU_ThrowOutOfMemoryError(env, 0); return 0;