diff options
author | Sonia Serafimova <sonia.serafimova@sonyericsson.com> | 2010-09-15 13:18:44 +0200 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-09-26 09:07:02 -0700 |
commit | d45a33554ca6c18ed81e45320998b9e4f4680379 (patch) | |
tree | 67a52d080094a2a46200387ba552e085bbb6e682 | |
parent | beabe75a842d521b005999460d3a6361ab32108e (diff) | |
download | frameworks_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.java | 18 |
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); } } |