Skip to content
Permalink
Browse files
8283225: ClassLoader.c produces incorrect OutOfMemory Exception when …
…length is 0 (aix)

Reviewed-by: stuefe, rriggs, dholmes
  • Loading branch information
backwaterred authored and tstuefe committed Mar 18, 2022
1 parent d83cee9 commit cab4ff64541393a974ea91e35167668ef0036804
Showing 1 changed file with 11 additions and 0 deletions.
@@ -99,7 +99,12 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
return 0;
}

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

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

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

if (body == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;

1 comment on commit cab4ff6

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on cab4ff6 Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.