Commit 6ef75c8b authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Fix numeric overflow in layer area calculation

BUG=1116788

Change-Id: I60c721d84b7c21406259ad8345d0290cb52ee940
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2358603
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799290}
parent fc9a2628
......@@ -109,10 +109,12 @@ void TableRowPainter::PaintBoxDecorationBackground(
paint_info_for_cells, layout_table_row_);
}
}
uint64_t paint_area = base::saturated_cast<uint64_t>(
paint_rect.Width().ToUnsigned() * paint_rect.Height().ToUnsigned());
paint_info.context.GetPaintController().SetPossibleBackgroundColor(
layout_table_row_,
layout_table_row_.ResolveColor(GetCSSPropertyBackgroundColor()).Rgb(),
paint_rect.Width().ToUnsigned() * paint_rect.Height().ToUnsigned());
paint_area);
}
if (has_box_shadow) {
......
......@@ -307,11 +307,13 @@ void TableSectionPainter::PaintBoxDecorationBackground(
}
}
}
uint64_t paint_area = base::saturated_cast<uint64_t>(
paint_rect.Width().ToUnsigned() * paint_rect.Height().ToUnsigned());
paint_info.context.GetPaintController().SetPossibleBackgroundColor(
layout_table_section_,
layout_table_section_.ResolveColor(GetCSSPropertyBackgroundColor())
.Rgb(),
paint_rect.Width().ToUnsigned() * paint_rect.Height().ToUnsigned());
paint_area);
}
if (has_box_shadow) {
......
......@@ -111,7 +111,8 @@ SkColor DrawingDisplayItem::BackgroundColor(uint64_t& area) const {
default:
continue;
}
area = static_cast<uint64_t>(item_rect.width() * item_rect.height());
area =
base::saturated_cast<uint64_t>(item_rect.width() * item_rect.height());
return flags.getColor();
}
return SK_ColorTRANSPARENT;
......
......@@ -123,8 +123,9 @@ void PaintArtifact::UpdateBackgroundColor(
layer->SetSafeOpaqueBackgroundColor(color);
uint64_t layer_area = layer->bounds().width() * layer->bounds().height();
if (area < layer_area / 2)
base::ClampedNumeric<uint64_t> layer_area = layer->bounds().width();
layer_area *= layer->bounds().height();
if (area < static_cast<uint64_t>(layer_area) / 2)
color = SK_ColorTRANSPARENT;
layer->SetBackgroundColor(color);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment