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

Commit 54285f2c authored by Phil Dubach's avatar Phil Dubach
Browse files

Fix NullPointerException in NinePatch constructor

NinePatch.mPaint may be null and most methods in this class handle
that case properly. However, the constructor which derives a new
NinePatch from an existing instance assumes that mPaint is non-null.
This results in an unexpected NullPointerException, for example when
attempting to call NinePatchDrawable.mutate() on an instance that was
created from a resource.

Small unrelated fix in same file: Remove unused private mRect member.
parent 72d19aa5
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -57,7 +57,9 @@ public class NinePatch {
        mBitmap = patch.mBitmap;
        mBitmap = patch.mBitmap;
        mChunk = patch.mChunk;
        mChunk = patch.mChunk;
        mSrcName = patch.mSrcName;
        mSrcName = patch.mSrcName;
        if (patch.mPaint != null) {
            mPaint = new Paint(patch.mPaint);
            mPaint = new Paint(patch.mPaint);
        }
        validateNinePatchChunk(mBitmap.ni(), mChunk);
        validateNinePatchChunk(mBitmap.ni(), mChunk);
    }
    }


@@ -120,7 +122,6 @@ public class NinePatch {
    
    
    public native static boolean isNinePatchChunk(byte[] chunk);
    public native static boolean isNinePatchChunk(byte[] chunk);


    private final Rect   mRect = new Rect();
    private final Bitmap mBitmap;
    private final Bitmap mBitmap;
    private final byte[] mChunk;
    private final byte[] mChunk;
    private Paint        mPaint;
    private Paint        mPaint;