summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Dubach <phillipd@google.com>2009-06-23 15:41:00 -0700
committerPhil Dubach <phillipd@google.com>2009-06-23 15:46:31 -0700
commit562bf17c6c7c5226b2220e27a1543d4a43543d6c (patch)
treeab5680ea262c8cfe81a1e3cc298398e81c657e2e
parent61ab270c17094ef1373f54d8fb9ade6d287c3a60 (diff)
downloadframeworks_base-562bf17c6c7c5226b2220e27a1543d4a43543d6c.zip
frameworks_base-562bf17c6c7c5226b2220e27a1543d4a43543d6c.tar.gz
frameworks_base-562bf17c6c7c5226b2220e27a1543d4a43543d6c.tar.bz2
Fix NPE in GradientDrawable constructor
The mColors member can be null, as can be seen in GradientDrawable.setSolidColor() or the plain constructor. In that case, an NPE will be thrown on attempts to derive a new GradientDrawable from the instance using the private constructor GradientDrawable(GradientDrawable). The problem also occurs when inflating a GradientDrawable from XML without defining the start, center and end colors and then calling mutate() on the instance.
-rw-r--r--graphics/java/android/graphics/drawable/GradientDrawable.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java
index 3db45f0..a7a8708 100644
--- a/graphics/java/android/graphics/drawable/GradientDrawable.java
+++ b/graphics/java/android/graphics/drawable/GradientDrawable.java
@@ -880,7 +880,9 @@ public class GradientDrawable extends Drawable {
mShape = state.mShape;
mGradient = state.mGradient;
mOrientation = state.mOrientation;
- mColors = state.mColors.clone();
+ if (state.mColors != null) {
+ mColors = state.mColors.clone();
+ }
if (state.mPositions != null) {
mPositions = state.mPositions.clone();
}