From dbbe2cc462f0dc21174362c7c0da377480bc698f Mon Sep 17 00:00:00 2001 From: Michael Starzinger Date: Sat, 6 Oct 2007 20:42:36 +0200 Subject: [PATCH] * src/native/jni.c (_Jv_JNI_DeleteLocalRef): Handle NULL references correctly. * src/native/localref.c (localref_add, localref_del): Added assertion. --- src/native/jni.c | 11 +++++++---- src/native/localref.c | 9 ++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/native/jni.c b/src/native/jni.c index 3b35b1174..5f3379ecb 100644 --- a/src/native/jni.c +++ b/src/native/jni.c @@ -1266,12 +1266,15 @@ jobject _Jv_JNI_PopLocalFrame(JNIEnv* env, jobject result) void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef) { - java_handle_t *o; + java_handle_t *o; STATISTICS(jniinvokation()); o = (java_handle_t *) localRef; + if (o == NULL) + return NULL; + /* delete the reference */ localref_del(o); @@ -1321,11 +1324,11 @@ jobject _Jv_JNI_NewLocalRef(JNIEnv *env, jobject ref) STATISTICS(jniinvokation()); - if (ref == NULL) - return NULL; - o = (java_handle_t *) ref; + if (o == NULL) + return NULL; + /* insert the reference */ localref = localref_add(LLNI_DIRECT(o)); diff --git a/src/native/localref.c b/src/native/localref.c index 728bfee28..e2781d1c8 100644 --- a/src/native/localref.c +++ b/src/native/localref.c @@ -327,17 +327,11 @@ java_handle_t *localref_add(java_object_t *o) java_handle_t *h; int32_t i; -#if !defined(NDEBUG) - if (o == NULL) { - log_println("localref_add: WARNING: trying to add localref for (NIL)!"); - return NULL; - } -#endif - /* get current local reference table from thread */ lrt = LOCALREFTABLE; assert(lrt != NULL); + assert(o != NULL); /* XXX: assert that we are in a GC critical section! */ /* Check if we have space for the requested reference? No, @@ -397,6 +391,7 @@ void localref_del(java_handle_t *localref) lrt = LOCALREFTABLE; assert(lrt != NULL); + assert(localref != NULL); localframes = lrt->localframes; -- 2.25.1