diff options
author | Brad Werth <bwerth@mozilla.com> | 2017-09-14 13:34:45 -0700 |
---|---|---|
committer | Brad Werth <werth@efn.org> | 2017-09-15 10:34:35 -0700 |
commit | 52dc4f438a08f14c80a086c1a1162d9a3ac1230d (patch) | |
tree | dcd7414707bbe6b56b3c2ee3676e229f5a62214e | |
parent | f1da967ef707bbc77f023daf28093201e96e19c5 (diff) | |
download | servo-52dc4f438a08f14c80a086c1a1162d9a3ac1230d.tar.gz servo-52dc4f438a08f14c80a086c1a1162d9a3ac1230d.zip |
Bug 1399941 Part 1: Prevent aspect-ratio media queries from causing multiplication overflow by extending values to u64.
MozReview-Commit-ID: e4kfxMDvZh
-rw-r--r-- | components/style/gecko/media_queries.rs | 4 |
1 files changed, 3 insertions, 1 deletions
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 { |