mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 07:38:22 +02:00
Prevent potentially infinite wandering through memeory in _cairo_hull_prev_valid
It is possible for _cairo_hull_prev_valid to be called just once right before the calling loop is going to terminate. In this case we really don't want to walk off the beginning of the array and start wandering. Thanks to Jonathan Watt for noticing this problem: https://bugzilla.mozilla.org/show_bug.cgi?id=306649#c21
This commit is contained in:
parent
c19133eb9a
commit
c26a7de970
1 changed files with 6 additions and 1 deletions
|
|
@ -125,8 +125,13 @@ _cairo_hull_vertex_compare (const void *av, const void *bv)
|
|||
static int
|
||||
_cairo_hull_prev_valid (cairo_hull_t *hull, int num_hull, int index)
|
||||
{
|
||||
/* hull[0] is always valid, and we never need to wraparound, (if
|
||||
* we are passed an index of 0 here, then the calling loop is just
|
||||
* about to terminate). */
|
||||
if (index == 0)
|
||||
return 0;
|
||||
|
||||
do {
|
||||
/* hull[0] is always valid, so don't test and wraparound */
|
||||
index--;
|
||||
} while (hull[index].discard);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue