From 0c6d83cc5625f967eb2e23cc7c232874cd9e60f9 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Thu, 1 Dec 2011 08:38:13 -0800 Subject: [PATCH] Protect code in ViewPropertyAnimator from potential null deref The monkeys threw a NullPointerException in ViewPropertyAnimator, from calling into a data structure that should have been not null. Not sure what weird onkey-driven timing issue caused the problem, but protecting the null deref is easy and safe. Issue 5626496 Change-Id: I902b510db60a8a85f776f48582ae0326522a9400 --- core/java/android/view/ViewPropertyAnimator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java index 84dc7d88f0616..89a1ef26918d7 100644 --- a/core/java/android/view/ViewPropertyAnimator.java +++ b/core/java/android/view/ViewPropertyAnimator.java @@ -837,6 +837,11 @@ public class ViewPropertyAnimator { */ @Override public void onAnimationUpdate(ValueAnimator animation) { + PropertyBundle propertyBundle = mAnimatorMap.get(animation); + if (propertyBundle == null) { + // Shouldn't happen, but just to play it safe + return; + } // alpha requires slightly different treatment than the other (transform) properties. // The logic in setAlpha() is not simply setting mAlpha, plus the invalidation // logic is dependent on how the view handles an internal call to onSetAlpha(). @@ -845,7 +850,6 @@ public class ViewPropertyAnimator { boolean alphaHandled = false; mView.invalidateParentCaches(); float fraction = animation.getAnimatedFraction(); - PropertyBundle propertyBundle = mAnimatorMap.get(animation); int propertyMask = propertyBundle.mPropertyMask; if ((propertyMask & TRANSFORM_MASK) != 0) { mView.invalidate(false);