Bug 1399941 Part 1: Prevent aspect-ratio media queries from causing multiplication overflow by extending values to u64.

MozReview-Commit-ID: e4kfxMDvZh
This commit is contained in:
Brad Werth 2017-09-14 13:34:45 -07:00 committed by Brad Werth
parent f1da967ef7
commit 52dc4f438a

View file

@ -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 {