Skip to content

Commit

Permalink
Bug 1399941 Part 1: Prevent aspect-ratio media queries from causing m…
Browse files Browse the repository at this point in the history
…ultiplication overflow by extending values to u64.

MozReview-Commit-ID: e4kfxMDvZh
  • Loading branch information
bradwerth committed Sep 15, 2017
1 parent f1da967 commit 52dc4f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/style/gecko/media_queries.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit 52dc4f4

Please sign in to comment.