From 52dc4f438a08f14c80a086c1a1162d9a3ac1230d Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Thu, 14 Sep 2017 13:34:45 -0700 Subject: [PATCH] Bug 1399941 Part 1: Prevent aspect-ratio media queries from causing multiplication overflow by extending values to u64. MozReview-Commit-ID: e4kfxMDvZh --- components/style/gecko/media_queries.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 415700fef6d..2765547aaf9 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -752,7 +752,9 @@ impl Expression { (&BoolInteger(one), &BoolInteger(ref other)) => one.cmp(other), (&Float(one), &Float(ref other)) => one.partial_cmp(other).unwrap(), (&IntRatio(one_num, one_den), &IntRatio(other_num, other_den)) => { - (one_num * other_den).partial_cmp(&(other_num * one_den)).unwrap() + // Extend to avoid overflow. + (one_num as u64 * other_den as u64).cmp( + &(other_num as u64 * one_den as u64)) } (&Resolution(ref one), &Resolution(ref other)) => { let actual_dpi = unsafe {