summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2010-12-13 11:13:32 -0800
committerJack Palevich <jackpal@google.com>2010-12-13 17:21:12 -0800
commitdee4cb07a3652457e18a0bf4be57d2cedeca7359 (patch)
treea220e8d123e7f6e0b5be972a1f9d75722ce8bfed
parent128b6ba93d0549fd2beff4482678e1229dc1cf3d (diff)
downloadframeworks_base-dee4cb07a3652457e18a0bf4be57d2cedeca7359.zip
frameworks_base-dee4cb07a3652457e18a0bf4be57d2cedeca7359.tar.gz
frameworks_base-dee4cb07a3652457e18a0bf4be57d2cedeca7359.tar.bz2
Avoid SIGSEGV in Bitmap_writeToParcel.
SkBitmap::getPixels() can return NULL. The rest of the JNI Bitmap code treats this NULL as if the SkBitmap has transparent black pixels. Bitmap_writeToParcel now does the same. Change-Id: I5e70b42b3d22a8aea898ce342e590000325bd0f9
-rw-r--r--core/jni/android/graphics/Bitmap.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 8956e39..29c6ba2 100644
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -429,7 +429,15 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
size_t size = bitmap->getSize();
bitmap->lockPixels();
- memcpy(p->writeInplace(size), bitmap->getPixels(), size);
+ void* pDst = p->writeInplace(size);
+
+ const void* pSrc = bitmap->getPixels();
+
+ if (pSrc == NULL) {
+ memset(pDst, 0, size);
+ } else {
+ memcpy(pDst, pSrc, size);
+ }
bitmap->unlockPixels();
return true;
}