* src/native/jni.c (_Jv_JNI_DeleteLocalRef): Handle NULL references correctly.
authorMichael Starzinger <michi@complang.tuwien.ac.at>
Sat, 6 Oct 2007 18:42:36 +0000 (20:42 +0200)
committerMichael Starzinger <michi@complang.tuwien.ac.at>
Sat, 6 Oct 2007 18:42:36 +0000 (20:42 +0200)
* src/native/localref.c (localref_add, localref_del): Added assertion.

src/native/jni.c
src/native/localref.c

index 3b35b1174583a51c47d4d62d423bb75ab7584617..5f3379ecbb80668e82438a8780ca003efa820e35 100644 (file)
@@ -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));
index 728bfee285cee4f28a0d724a521d24eea1c9242e..e2781d1c8e3fbce2ac109fd472578fb15c4dc7fa 100644 (file)
@@ -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;