From b3cbe0fdb983a2cc76635a5b70a1048534c973c0 Mon Sep 17 00:00:00 2001 From: Nicolas Ramz Date: Wed, 15 Nov 2023 10:39:26 +0100 Subject: [PATCH] LibGfx/Path: Round numerator in elliptical_arc_to This avoids rounding problems which made Ladybird crash with some SVGs on macOS/Clang. --- Userland/Libraries/LibGfx/Path.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/Path.cpp b/Userland/Libraries/LibGfx/Path.cpp index 97df60b258..ed5a19dcf6 100644 --- a/Userland/Libraries/LibGfx/Path.cpp +++ b/Userland/Libraries/LibGfx/Path.cpp @@ -127,7 +127,7 @@ void Path::elliptical_arc_to(FloatPoint point, FloatSize radii, float x_axis_rot } else { double numerator = rx_sq * ry_sq - rx_sq * y1p_sq - ry_sq * x1p_sq; double denominator = rx_sq * y1p_sq + ry_sq * x1p_sq; - multiplier = AK::sqrt(numerator / denominator); + multiplier = AK::sqrt(AK::max(0., numerator) / denominator); } if (large_arc == sweep)