[cairo] [PATCH] Don't leak memory upon failed realloc.

Jim Meyering jim at meyering.net
Sat Dec 15 07:42:25 PST 2007


* cairo-glitz-surface.c (_cairo_glitz_surface_composite_trapezoids):

Signed-off-by: Jim Meyering <meyering at redhat.com>
---
 src/cairo-glitz-surface.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c
index eb68b43..05e80db 100644
--- a/src/cairo-glitz-surface.c
+++ b/src/cairo-glitz-surface.c
@@ -1305,9 +1305,10 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t  op,
 	{
 	    if (data_size < size)
 	    {
+		void *p;
 		data_size = size;
-		data = realloc (data, data_size);
-		if (!data)
+		p = realloc (data, data_size);
+		if (!p)
 		{
 		    _cairo_glitz_pattern_release_surface (src_pattern, src,
 							  &attributes);
@@ -1315,6 +1316,7 @@ _cairo_glitz_surface_composite_trapezoids (cairo_operator_t  op,
 			_cairo_pattern_fini (&tmp_src_pattern.base);
 		    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 		}
+		data = p;

 		if (buffer)
 		    glitz_buffer_destroy (buffer);
--
1.5.4.rc0.36.g7680


More information about the cairo mailing list