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:
Carl Worth 2008-04-08 01:54:27 -07:00
parent c19133eb9a
commit c26a7de970

View file

@ -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);