Fixes crash when constructing NinePatch with null chunk data

Previously, ART runtime would crash checking the size of the
chunk array if it was null. Now we simply set the chunk size to
zero and fail with an exception, the same as when the array is not
large enough.

Test: NinePatchTest#testConstructor
Fixes: 189478462
Change-Id: I0352a9b6be1ce64c6a40ce8dffdaa146aacb7a03
This commit is contained in:
Chet Haase
2021-07-26 20:45:17 +00:00
parent 7f1c09cb10
commit 34def796c9

View File

@@ -64,7 +64,7 @@ public:
}
static jlong validateNinePatchChunk(JNIEnv* env, jobject, jbyteArray obj) {
size_t chunkSize = env->GetArrayLength(obj);
size_t chunkSize = obj != NULL ? env->GetArrayLength(obj) : 0;
if (chunkSize < (int) (sizeof(Res_png_9patch))) {
jniThrowRuntimeException(env, "Array too small for chunk.");
return NULL;