summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSonia Serafimova <sonia.serafimova@sonyericsson.com>2010-09-15 13:18:44 +0200
committerJean-Baptiste Queru <jbq@google.com>2010-09-26 09:07:02 -0700
commitd45a33554ca6c18ed81e45320998b9e4f4680379 (patch)
tree67a52d080094a2a46200387ba552e085bbb6e682
parentbeabe75a842d521b005999460d3a6361ab32108e (diff)
downloadframeworks_base-d45a33554ca6c18ed81e45320998b9e4f4680379.zip
frameworks_base-d45a33554ca6c18ed81e45320998b9e4f4680379.tar.gz
frameworks_base-d45a33554ca6c18ed81e45320998b9e4f4680379.tar.bz2
Prevent unhandled exception in NinePatchDrawable
Added null check in computeBitmapSize() to avoid unhandled exception "java.lang.NullPointerException" at android.graphics.Rect.<init>(Rect.java:72). This problem was discovered in the wild. Change-Id: I9d40629a052f1390e1811288af6209d8cc3f679b
-rw-r--r--graphics/java/android/graphics/drawable/NinePatchDrawable.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/drawable/NinePatchDrawable.java b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
index bad94fb..00416d8 100644
--- a/graphics/java/android/graphics/drawable/NinePatchDrawable.java
+++ b/graphics/java/android/graphics/drawable/NinePatchDrawable.java
@@ -164,15 +164,17 @@ public class NinePatchDrawable extends Drawable {
sdensity, tdensity);
mBitmapHeight = Bitmap.scaleFromDensity(mNinePatch.getHeight(),
sdensity, tdensity);
- Rect dest = mPadding;
- Rect src = mNinePatchState.mPadding;
- if (dest == src) {
- mPadding = dest = new Rect(src);
+ if (mNinePatchState.mPadding != null && mPadding != null) {
+ Rect dest = mPadding;
+ Rect src = mNinePatchState.mPadding;
+ if (dest == src) {
+ mPadding = dest = new Rect(src);
+ }
+ dest.left = Bitmap.scaleFromDensity(src.left, sdensity, tdensity);
+ dest.top = Bitmap.scaleFromDensity(src.top, sdensity, tdensity);
+ dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity);
+ dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity);
}
- dest.left = Bitmap.scaleFromDensity(src.left, sdensity, tdensity);
- dest.top = Bitmap.scaleFromDensity(src.top, sdensity, tdensity);
- dest.right = Bitmap.scaleFromDensity(src.right, sdensity, tdensity);
- dest.bottom = Bitmap.scaleFromDensity(src.bottom, sdensity, tdensity);
}
}