From 036b495cb253f668e88c11813f750b0e537a32bd Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 10 Jul 2019 23:12:26 -0700 Subject: [PATCH] Error on invalid rotation values in XRRigidTransform constructor --- components/script/dom/xrrigidtransform.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/script/dom/xrrigidtransform.rs b/components/script/dom/xrrigidtransform.rs index 5e1f720411e..ca73121d931 100644 --- a/components/script/dom/xrrigidtransform.rs +++ b/components/script/dom/xrrigidtransform.rs @@ -77,6 +77,12 @@ impl XRRigidTransform { orientation.z as f32, orientation.w as f32, ); + + if !rotate.i.is_finite() { + // if quaternion has zero norm, we'll get an infinite or NaN + // value for each element. This is preferable to checking for zero. + return Err(Error::InvalidState); + } let transform = TypedRigidTransform3D::new(rotate, translate); Ok(XRRigidTransform::new(&window.global(), transform)) }