-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
5.0u31, 6u3, 7u4
Our source licensee has hit a crash in a particular scenario when the
memory limit is reached and they are trying to create an array using
NewIntArray(). In this case NewIntArray() returns NULL. As we don’t have the
NULL check for javaResult, this leads to crash later.
This issue is seen with JDK 5.0 , 6.0 & 7.0 too . From the suggested
change below, our understanding is that this is platform independent. The
following are the suggested changes:
--- FileSystemPreferences.c (revision 6511)
+++ FileSystemPreferences.c (working copy)
@@ -136,6 +136,10 @@
}
JNU_ReleaseStringPlatformChars(env, java_fname, fname);
javaResult = (*env)->NewIntArray(env,2);
+ if (javaResult == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
(*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
return javaResult;
}
memory limit is reached and they are trying to create an array using
NewIntArray(). In this case NewIntArray() returns NULL. As we don’t have the
NULL check for javaResult, this leads to crash later.
This issue is seen with JDK 5.0 , 6.0 & 7.0 too . From the suggested
change below, our understanding is that this is platform independent. The
following are the suggested changes:
--- FileSystemPreferences.c (revision 6511)
+++ FileSystemPreferences.c (working copy)
@@ -136,6 +136,10 @@
}
JNU_ReleaseStringPlatformChars(env, java_fname, fname);
javaResult = (*env)->NewIntArray(env,2);
+ if (javaResult == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "Out of Memory");
+ return -1;
+ }
(*env)->SetIntArrayRegion(env, javaResult, 0, 2, result);
return javaResult;
}