OSDN Git Service

* jni.cc (_Jv_JNI_NewObjectArray): Check that initializer can be
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2003 22:50:48 +0000 (22:50 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 31 Jan 2003 22:50:48 +0000 (22:50 +0000)
cast to element type.
(_Jv_JNI_SetObjectArrayElement): Check array bounds.
(_Jv_JNI_GetObjectArrayElement): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62210 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/jni.cc

index 028f1ae..c060e1c 100644 (file)
@@ -1,5 +1,10 @@
 2003-01-31  Tom Tromey  <tromey@redhat.com>
 
+       * jni.cc (_Jv_JNI_NewObjectArray): Check that initializer can be
+       cast to element type.
+       (_Jv_JNI_SetObjectArrayElement): Check array bounds.
+       (_Jv_JNI_GetObjectArrayElement): Likewise.
+
        * Makefile.in: Rebuilt.
        * Makefile.am (cond_x_ltlibrary): Renamed library to
        lib-gnu-awt-xlib.la.
index b841b4f..c1a2880 100644 (file)
@@ -1,6 +1,6 @@
 // jni.cc - JNI implementation, including the jump table.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -1388,6 +1388,7 @@ static jarray
       elementClass = unwrap (elementClass);
       init = unwrap (init);
 
+      _Jv_CheckCast (elementClass, init);
       jarray result = JvNewObjectArray (length, elementClass, init);
       return (jarray) wrap_value (env, result);
     }
@@ -1402,6 +1403,8 @@ static jobject
 (JNICALL _Jv_JNI_GetObjectArrayElement) (JNIEnv *env, jobjectArray array, 
                                          jsize index)
 {
+  if ((unsigned) index >= (unsigned) array->length)
+    _Jv_ThrowBadArrayIndex (index);
   jobject *elts = elements (unwrap (array));
   return wrap_value (env, elts[index]);
 }
@@ -1416,6 +1419,8 @@ static void
       value = unwrap (value);
 
       _Jv_CheckArrayStore (array, value);
+      if ((unsigned) index >= (unsigned) array->length)
+       _Jv_ThrowBadArrayIndex (index);
       jobject *elts = elements (array);
       elts[index] = value;
     }