From 332dd900af8b66403a2786c71092cd819098d1a4 Mon Sep 17 00:00:00 2001 From: Martin Ejdestig Date: Fri, 17 Aug 2007 02:28:35 +0200 Subject: [PATCH] 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. --- src/cairo-image-surface.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 9f933e2..3059e78 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -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. * -- 1.5.2.4