summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Dubach <phillipd@google.com>2009-06-29 20:34:13 -0700
committerPhil Dubach <phillipd@google.com>2009-06-30 13:19:48 -0700
commit54285f2cbfb6e307d594ca264f7230b4e1e3cdce (patch)
treec8041a76c8a31c76916dc27085a87be207292cae
parent72d19aa51e90d45c7895629db78e548da2f6d469 (diff)
downloadframeworks_base-54285f2cbfb6e307d594ca264f7230b4e1e3cdce.zip
frameworks_base-54285f2cbfb6e307d594ca264f7230b4e1e3cdce.tar.gz
frameworks_base-54285f2cbfb6e307d594ca264f7230b4e1e3cdce.tar.bz2
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.
-rw-r--r--graphics/java/android/graphics/NinePatch.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java
index 2b24ef2..778c903 100644
--- a/graphics/java/android/graphics/NinePatch.java
+++ b/graphics/java/android/graphics/NinePatch.java
@@ -57,7 +57,9 @@ public class NinePatch {
mBitmap = patch.mBitmap;
mChunk = patch.mChunk;
mSrcName = patch.mSrcName;
- mPaint = new Paint(patch.mPaint);
+ if (patch.mPaint != null) {
+ mPaint = new Paint(patch.mPaint);
+ }
validateNinePatchChunk(mBitmap.ni(), mChunk);
}
@@ -120,7 +122,6 @@ public class NinePatch {
public native static boolean isNinePatchChunk(byte[] chunk);
- private final Rect mRect = new Rect();
private final Bitmap mBitmap;
private final byte[] mChunk;
private Paint mPaint;