aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/xrrigidtransform.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2019-07-10 23:12:26 -0700
committerManish Goregaokar <manishsmail@gmail.com>2019-07-11 11:12:59 -0700
commit036b495cb253f668e88c11813f750b0e537a32bd (patch)
tree550378fbdff2b9abd957219d8d336214b606e134 /components/script/dom/xrrigidtransform.rs
parent0b88c565c544afe710cc6019f8e90c8d1ed8cfbb (diff)
downloadservo-036b495cb253f668e88c11813f750b0e537a32bd.tar.gz
servo-036b495cb253f668e88c11813f750b0e537a32bd.zip
Error on invalid rotation values in XRRigidTransform constructor
Diffstat (limited to 'components/script/dom/xrrigidtransform.rs')
-rw-r--r--components/script/dom/xrrigidtransform.rs6
1 files changed, 6 insertions, 0 deletions
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))
}