jni.cc (_Jv_JNI_NewObjectArray): Check that initializer can be cast to element type.

* jni.cc (_Jv_JNI_NewObjectArray): Check that initializer can be
	cast to element type.
	(_Jv_JNI_SetObjectArrayElement): Check array bounds.
	(_Jv_JNI_GetObjectArrayElement): Likewise.

From-SVN: r62210
This commit is contained in:
Tom Tromey 2003-01-31 22:50:48 +00:00 committed by Tom Tromey
parent 0120f3d478
commit 9bc825c4ba
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,10 @@
2003-01-31 Tom Tromey <tromey@redhat.com> 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.in: Rebuilt.
* Makefile.am (cond_x_ltlibrary): Renamed library to * Makefile.am (cond_x_ltlibrary): Renamed library to
lib-gnu-awt-xlib.la. lib-gnu-awt-xlib.la.

View File

@ -1,6 +1,6 @@
// jni.cc - JNI implementation, including the jump table. // 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. This file is part of libgcj.
@ -1388,6 +1388,7 @@ static jarray
elementClass = unwrap (elementClass); elementClass = unwrap (elementClass);
init = unwrap (init); init = unwrap (init);
_Jv_CheckCast (elementClass, init);
jarray result = JvNewObjectArray (length, elementClass, init); jarray result = JvNewObjectArray (length, elementClass, init);
return (jarray) wrap_value (env, result); return (jarray) wrap_value (env, result);
} }
@ -1402,6 +1403,8 @@ static jobject
(JNICALL _Jv_JNI_GetObjectArrayElement) (JNIEnv *env, jobjectArray array, (JNICALL _Jv_JNI_GetObjectArrayElement) (JNIEnv *env, jobjectArray array,
jsize index) jsize index)
{ {
if ((unsigned) index >= (unsigned) array->length)
_Jv_ThrowBadArrayIndex (index);
jobject *elts = elements (unwrap (array)); jobject *elts = elements (unwrap (array));
return wrap_value (env, elts[index]); return wrap_value (env, elts[index]);
} }
@ -1416,6 +1419,8 @@ static void
value = unwrap (value); value = unwrap (value);
_Jv_CheckArrayStore (array, value); _Jv_CheckArrayStore (array, value);
if ((unsigned) index >= (unsigned) array->length)
_Jv_ThrowBadArrayIndex (index);
jobject *elts = elements (array); jobject *elts = elements (array);
elts[index] = value; elts[index] = value;
} }