From 34def796c98539e23e86d2d3728d46ab3c4a79da Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Mon, 26 Jul 2021 20:45:17 +0000 Subject: [PATCH] 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 --- libs/hwui/jni/NinePatch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwui/jni/NinePatch.cpp b/libs/hwui/jni/NinePatch.cpp index 6942017d5f275..b7ddd211b0de5 100644 --- a/libs/hwui/jni/NinePatch.cpp +++ b/libs/hwui/jni/NinePatch.cpp @@ -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;