summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorSonia Serafimova <sonia.serafimova@sonyericsson.com>2010-09-15 13:18:44 +0200
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-09-15 13:22:43 +0200
commit279d006b1d194c597a4c6b0a72f66ea6128851fa (patch)
treea89ac61097ee600c0449148246c6803aa0ebf569 /graphics
parent15f0a79a81fd18211603587bcd46eee0e37ced4d (diff)
downloadframeworks_base-279d006b1d194c597a4c6b0a72f66ea6128851fa.zip
frameworks_base-279d006b1d194c597a4c6b0a72f66ea6128851fa.tar.gz
frameworks_base-279d006b1d194c597a4c6b0a72f66ea6128851fa.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: I8a4729ceadcfc9744f11b8ceafdf24d6de88c645
Diffstat (limited to 'graphics')
-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);
}
}