Skip to content

Commit 68339be

Browse files
author
duke
committedMar 18, 2022
Automatic merge of jdk:master into master
2 parents 269d74e + cab4ff6 commit 68339be

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎src/java.base/share/native/libjava/ClassLoader.c

+11
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
9999
return 0;
100100
}
101101

102+
// On AIX malloc(0) returns NULL which looks like an out-of-memory condition; so adjust it to malloc(1)
103+
#ifdef _AIX
104+
body = (jbyte *)malloc(length == 0 ? 1 : length);
105+
#else
102106
body = (jbyte *)malloc(length);
107+
#endif
103108

104109
if (body == 0) {
105110
JNU_ThrowOutOfMemoryError(env, 0);
@@ -239,7 +244,13 @@ Java_java_lang_ClassLoader_defineClass0(JNIEnv *env,
239244
return 0;
240245
}
241246

247+
// On AIX malloc(0) returns NULL which looks like an out-of-memory condition; so adjust it to malloc(1)
248+
#ifdef _AIX
249+
body = (jbyte *)malloc(length == 0 ? 1 : length);
250+
#else
242251
body = (jbyte *)malloc(length);
252+
#endif
253+
243254
if (body == 0) {
244255
JNU_ThrowOutOfMemoryError(env, 0);
245256
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.