Avoid assert when drawing arcs with NaN angles

I hit the problem with _cairo_arc_in_direction() failing the
angle_max >= angle_min assertion earlier this year when using
Thunderbird on openSUSE Tumbleweed.  Thunderbird would crash
when rendering some (but not all) HTML email due to this
assert.  For some reason, one of the angles passed in was
NaN.  Making _cairo_arc_in_direction() return immediately if
either angle is not finite fixed the problem for me, but I
don't know enough about the internals of Cairo to know if
this is, strictly speaking, the "right" fix.  Also, having
tested again today _without_ this change applied, I am now
no longer able to reproduce the problem :-/  I still have the
same version of Cairo installed (1.17.8), but various other
packages on that system have been updated in the meantime,
so maybe that's a factor.  Or maybe I'm just lucky and
haven't hit a "bad" HTML email this time...?

Fixes: https://gitlab.freedesktop.org/cairo/cairo/-/issues/352
Signed-off-by: Tim Serong <tserong@suse.com>
This commit is contained in:
Tim Serong 2023-09-19 18:18:28 +10:00
parent c45e373fb4
commit 09643ee1ab

View file

@ -188,6 +188,9 @@ _cairo_arc_in_direction (cairo_t *cr,
if (cairo_status (cr))
return;
if (! ISFINITE (angle_max) || ! ISFINITE (angle_min))
return;
assert (angle_max >= angle_min);
if (angle_max - angle_min > 2 * M_PI * MAX_FULL_CIRCLES) {