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:
Jack Palevich
2010-12-13 11:13:32 -08:00
parent 128b6ba93d
commit dee4cb07a3

View File

@@ -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;
}