diff --git a/libjava/ChangeLog b/libjava/ChangeLog index eaec78d008e..49142ac3ada 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2000-02-15 Tom Tromey + + * jni.cc (_Jv_JNI_AttachCurrentThread): Return error if malloc + fails. + 2000-02-15 Bryce McKinlay * NEWS: Updated. diff --git a/libjava/jni.cc b/libjava/jni.cc index 6beb6f7f8a4..48c63b05bf1 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -1415,16 +1415,21 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args) 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 (env); java::lang::Thread *t = new gnu::gcj::jni::NativeThread (group, name);