jni.cc (_Jv_JNI_AttachCurrentThread): Return error if malloc fails.

* jni.cc (_Jv_JNI_AttachCurrentThread): Return error if malloc
	fails.

From-SVN: r31986
This commit is contained in:
Tom Tromey 2000-02-15 20:39:36 +00:00 committed by Tom Tromey
parent fa545500ad
commit 2d759f7165
2 changed files with 12 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2000-02-15 Tom Tromey <tromey@cygnus.com>
* jni.cc (_Jv_JNI_AttachCurrentThread): Return error if malloc
fails.
2000-02-15 Bryce McKinlay <bryce@albatross.co.nz> 2000-02-15 Bryce McKinlay <bryce@albatross.co.nz>
* NEWS: Updated. * NEWS: Updated.

View File

@ -1415,16 +1415,21 @@ _Jv_JNI_AttachCurrentThread (JavaVM *, jstring name, void **penv, void *args)
if (_Jv_ThreadCurrent () != NULL) if (_Jv_ThreadCurrent () != NULL)
return 0; return 0;
// FIXME: NULL return?
JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv)); JNIEnv *env = (JNIEnv *) _Jv_MallocUnchecked (sizeof (JNIEnv));
if (env == NULL)
return JNI_ERR;
env->p = &_Jv_JNIFunctions; env->p = &_Jv_JNIFunctions;
env->ex = NULL; env->ex = NULL;
env->klass = NULL; env->klass = NULL;
// FIXME: NULL return?
env->locals env->locals
= (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame) = (_Jv_JNI_LocalFrame *) _Jv_MallocUnchecked (sizeof (_Jv_JNI_LocalFrame)
+ (FRAME_SIZE + (FRAME_SIZE
* sizeof (jobject))); * sizeof (jobject)));
if (env->locals == NULL)
{
_Jv_Free (env);
return JNI_ERR;
}
*penv = reinterpret_cast<void *> (env); *penv = reinterpret_cast<void *> (env);
java::lang::Thread *t = new gnu::gcj::jni::NativeThread (group, name); java::lang::Thread *t = new gnu::gcj::jni::NativeThread (group, name);