Plug possible leak of pixman_traps in _cairo_image_surface_composite_trapezoids.

If width and height are 0 and pixman_traps is allocated on the heap,
it would leak. Fix by simply checking width and height prior to
allocating pixman_traps.
This commit is contained in:
Martin Ejdestig 2007-08-17 02:28:35 +02:00 committed by Chris Wilson
parent 507d7ee099
commit 39367b2612

View file

@ -901,6 +901,9 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
int mask_bpp;
int ret, i;
if (height == 0 || width == 0)
return CAIRO_STATUS_SUCCESS;
/* Convert traps to pixman traps */
if (num_traps > ARRAY_LENGTH(stack_traps)) {
pixman_traps = _cairo_malloc_ab (num_traps, sizeof(pixman_trapezoid_t));
@ -921,9 +924,6 @@ _cairo_image_surface_composite_trapezoids (cairo_operator_t op,
pixman_traps[i].right.p2.y = _cairo_fixed_to_16_16 (traps[i].right.p2.y);
}
if (height == 0 || width == 0)
return CAIRO_STATUS_SUCCESS;
/* Special case adding trapezoids onto a mask surface; we want to avoid
* creating an intermediate temporary mask unnecessarily.
*