From dde0f32724a72888d4d962cef5337b5c624b8544 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Fri, 31 Mar 2017 17:47:41 +0800 Subject: [PATCH] Bug 1352067 - Initialize StyleAnimationValue with zeros. AnimationValue::mGecko and AnimationValue::mServo are mutually exclusive, so we have to make sure mGecko.IsNull() returns reasonable value, or we will got assertions. Hence, we should initialize it during constructing StyleAnimationValue from Servo side. --- ports/geckolib/glue.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 9c5f63489aa..1ce2e02b216 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1551,6 +1551,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis raw_data: RawServoStyleSetBorrowed, computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut) { + use std::mem; use style::properties::LonghandIdSet; use style::properties::declaration_block::Importance; use style::values::computed::Context; @@ -1614,6 +1615,10 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis unsafe { animation_values.set_len((i + 1) as u32) }; seen.set_transition_property_bit(&anim.0); animation_values[i].mProperty = anim.0.into(); + // We only make sure we have enough space for this variable, + // but didn't construct a default value for StyleAnimationValue, + // so we should zero it to avoid getting undefined behaviors. + animation_values[i].mValue.mGecko = unsafe { mem::zeroed() }; animation_values[i].mValue.mServo.set_arc_leaky(Arc::new(anim.1)); } }