This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Patch: JNI fixlet
- To: Java Patch List <java-patches at sourceware dot cygnus dot com>
- Subject: Patch: JNI fixlet
- From: Tom Tromey <tromey at cygnus dot com>
- Date: 15 Feb 2000 13:33:28 -0700
- Reply-To: tromey at cygnus dot com
I'm checking in the appended patch, which fixes a small bug in jni.cc.
2000-02-15 Tom Tromey <tromey@cygnus.com>
* jni.cc (_Jv_JNI_AttachCurrentThread): Return error if malloc
fails.
Tom
Index: jni.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/jni.cc,v
retrieving revision 1.13
diff -u -r1.13 jni.cc
--- jni.cc 2000/02/10 20:31:47 1.13
+++ jni.cc 2000/02/15 19:57:52
@@ -1415,16 +1415,21 @@
if (_Jv_ThreadCurrent () != NULL)
return 0;
- // FIXME: NULL return?
JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
+ if (env == NULL)
+ return JNI_ERR;
env->p = &_Jv_JNIFunctions;
env->ex = NULL;
env->klass = NULL;
- // FIXME: NULL return?
env->locals
= (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame)
+ (FRAME_SIZE
* sizeof (jobject)));
+ if (env->locals == NULL)
+ {
+ _Jv_Free (env);
+ return JNI_ERR;
+ }
*penv = reinterpret_cast<void *> (env);
java::lang::Thread *t = new gnu::gcj::jni::NativeThread (group, name);