From 66ce1c3b1a7b5ed3d4d5a9a05a7c133998c9a73e Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 2 Feb 2016 11:11:55 -0500 Subject: [PATCH] Lock SkBitmap before accessing color table This only affects kIndex_8 Bitmaps, which can only be created by decoding particular images (e.g. GIF). Without locking the SkBitmap, colorTable() always returns NULL. Lock it so we can write the color table to the Parcel. BUG:26527976 Change-Id: Ifc54b06ca08db26ba6455a3830b7e671b64f37c4 --- core/jni/android/graphics/Bitmap.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 80ccb614ad734..43e26b332f11e 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -1087,6 +1087,8 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, p->writeInt32(density); if (bitmap.colorType() == kIndex_8_SkColorType) { + // The bitmap needs to be locked to access its color table. + SkAutoLockPixels alp(bitmap); SkColorTable* ctable = bitmap.getColorTable(); if (ctable != NULL) { int count = ctable->count();