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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user