Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dee4cb07 authored by Jack Palevich's avatar Jack Palevich
Browse files

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
parent 128b6ba9
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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;
}