Ensure JNI primitive array type is appropriate.
Check the primitive array type for GetPrimitiveArray, ReleasePrimitiveArray,
GetPrimitiveArrayRegion and SetPrimitiveArrayRegion matches the given array
type. Check the GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical are
given a primitive array.
Add unit tests that null parameters lead to fatal errors, not crashes. Fix
issues where CheckJNI assumed non-null arguments.
Tidy testing code via the use of nullptr. Add a few extra checks.
Ensure arrays of void are not able to be created, use RI compatible
NoClassDefError.
Bug: 14817823
Change-Id: I9903bcd800d0da1988ced07f61fb97b783c5deab
diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc
index 3df050e..1e44e6a 100644
--- a/runtime/check_jni.cc
+++ b/runtime/check_jni.cc
@@ -179,7 +179,7 @@
// times, so using "java.lang.Thread" instead of "java/lang/Thread" might work in some
// circumstances, but this is incorrect.
void CheckClassName(const char* class_name) {
- if (!IsValidJniClassName(class_name)) {
+ if ((class_name == nullptr) || !IsValidJniClassName(class_name)) {
JniAbortF(function_name_,
"illegal class name '%s'\n"
" (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')",