summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Leon Scroggins III <scroggo@google.com> 2021-10-01 16:35:46 -0400
committer Leon Scroggins III <scroggo@google.com> 2024-06-07 15:25:27 -0400
commit3eb6c88b447fe633f1ec1f3a1a6377e4975189d2 (patch)
tree406dd1dad1f74c84b803fb9128d39401ff27584a
parent309fdfc8e9b194e1b8671d2a561db26784468be6 (diff)
Check for (and clear) Exceptions thrown by TransferParameters
In GraphicsJNI::getColorSpace, which returns an android.graphics.ColorSpace for a Bitmap, Skia reads the encoded transfer function which then gets passed to the TransferParameters constructor. It's possible for that constructor to throw an Exception, in which case we cannot call JNI functions without handling the Exception. Clear it and return null, since we are now unable to create an android.graphics.ColorSpace. Bug: 198155681 Test: I805aba8c078aac71d92ea71a199c2e1fe52df8fd Flag: EXEMPT trivial bug fix Change-Id: Ib1f7cbcc62a4722a2379b111838584cc4b6a36cc
-rw-r--r--libs/hwui/jni/Graphics.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/libs/hwui/jni/Graphics.cpp b/libs/hwui/jni/Graphics.cpp
index 07e97f85d588..a88139d6b5d6 100644
--- a/libs/hwui/jni/Graphics.cpp
+++ b/libs/hwui/jni/Graphics.cpp
@@ -583,6 +583,16 @@ jobject GraphicsJNI::getColorSpace(JNIEnv* env, SkColorSpace* decodeColorSpace,
transferParams.a, transferParams.b, transferParams.c, transferParams.d,
transferParams.e, transferParams.f, transferParams.g);
+ // Some transfer functions that are considered valid by Skia are not
+ // accepted by android.graphics.
+ if (hasException(env)) {
+ // Callers (e.g. Bitmap#getColorSpace) are not expected to throw an
+ // Exception, so clear it and return null, which is a documented
+ // possibility.
+ env->ExceptionClear();
+ return nullptr;
+ }
+
jfloatArray xyzArray = env->NewFloatArray(9);
jfloat xyz[9] = {
xyzMatrix.vals[0][0],