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

Commit cd93864b authored by Michal Stawinski's avatar Michal Stawinski Committed by elektroschmock
Browse files

Fix SkBitmap::fPixels not being locked correctly

In some cases bitmap's pixels where freed during encoding, which
caused a null pointer dereference.
This fix makes sure that underlaying buffer is locked for the whole
process of compression.

Change-Id: I0ac56821f5d333072271dc2670fa30f1562adfa3
parent 9366afd0
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -298,8 +298,18 @@ static bool Bitmap_compress(JNIEnv* env, jobject clazz, SkBitmap* bitmap,
    }

    bool success = false;
    if (NULL != bitmap) {
        SkAutoLockPixels alp(*bitmap);

        if (NULL == bitmap->getPixels()) {
            return false;
        }

        SkWStream* strm = CreateJavaOutputStreamAdaptor(env, jstream, jstorage);
    if (NULL != strm) {
        if (NULL == strm) {
            return false;
        }

        SkImageEncoder* encoder = SkImageEncoder::Create(fm);
        if (NULL != encoder) {
            success = encoder->encodeStream(strm, *bitmap, quality);