From 9070aaebee4eab8af3853907c07e0e13cde28f5c Mon Sep 17 00:00:00 2001 From: MacDue Date: Thu, 11 May 2023 22:20:38 +0100 Subject: [PATCH] LibGfx: VERIFY() error is finite when splitting bezier curves If this value somehow becomes nan/inf the painter will keep splitting the path till the process OOMs, a simple crash would be preferable. --- Userland/Libraries/LibGfx/Painter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index bf36aeace2..0b60926a2e 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -2128,7 +2128,10 @@ static bool can_approximate_bezier_curve(FloatPoint p1, FloatPoint p2, FloatPoin p2x = p2x * p2x; p2y = p2y * p2y; - return max(p1x, p2x) + max(p1y, p2y) <= tolerance; + auto error = max(p1x, p2x) + max(p1y, p2y); + VERIFY(isfinite(error)); + + return error <= tolerance; } // static @@ -2202,7 +2205,10 @@ static bool can_approximate_cubic_bezier_curve(FloatPoint p1, FloatPoint p2, Flo bx *= bx; by *= by; - return max(ax, bx) + max(ay, by) <= tolerance; + auto error = max(ax, bx) + max(ay, by); + VERIFY(isfinite(error)); + + return error <= tolerance; } // static