LibWeb: Ignore non-finite args in CanvasRenderingContext2D::clear_rect()

This commit is contained in:
ljamar 2025-10-12 02:55:37 +02:00 committed by Luke Wilde
parent b1801c0bc9
commit 7fb65283c2
Notes: github-actions[bot] 2025-10-17 16:43:13 +00:00
3 changed files with 63 additions and 0 deletions

View file

@ -100,8 +100,13 @@ void CanvasRenderingContext2D::fill_rect(float x, float y, float width, float he
fill_internal(rect_path(x, y, width, height), Gfx::WindingRule::EvenOdd);
}
// https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clearrect
void CanvasRenderingContext2D::clear_rect(float x, float y, float width, float height)
{
// 1. If any of the arguments are infinite or NaN, then return.
if (!isfinite(x) || !isfinite(y) || !isfinite(width) || !isfinite(height))
return;
if (auto* painter = this->painter()) {
auto rect = Gfx::FloatRect(x, y, width, height);
painter->clear_rect(rect, clear_color());