From ba5c45deaf2fd6297f2832a225c7fca2c4732793 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 11 May 2011 11:21:18 -0400 Subject: [PATCH] st-private: Correct fix for memory leak The previous fix in 72f9f482d was wrong; we need to keep around the buffer until cairo is done with the pattern. https://bugzilla.gnome.org/show_bug.cgi?id=649497 --- src/st/st-private.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/st/st-private.c b/src/st/st-private.c index 51798a1f8..21ca09a9e 100644 --- a/src/st/st-private.c +++ b/src/st/st-private.c @@ -667,6 +667,7 @@ cairo_pattern_t * _st_create_shadow_cairo_pattern (StShadow *shadow_spec, cairo_pattern_t *src_pattern) { + static cairo_user_data_key_t shadow_pattern_user_data; cairo_t *cr; cairo_surface_t *src_surface; cairo_surface_t *surface_in; @@ -728,6 +729,8 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec, width_out, height_out, rowstride_out); + cairo_surface_set_user_data (surface_out, &shadow_pattern_user_data, + pixels_out, (cairo_destroy_func_t) g_free); dst_pattern = cairo_pattern_create_for_surface (surface_out); cairo_surface_destroy (surface_out); @@ -745,8 +748,7 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec, (width_out - width_in) / 2.0, (height_out - height_in) / 2.0); cairo_pattern_set_matrix (dst_pattern, &shadow_matrix); - - goto out; + return dst_pattern; } /* Read all the code from the cairo_pattern_set_matrix call @@ -784,8 +786,6 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec, cairo_pattern_set_matrix (dst_pattern, &shadow_matrix); - out: - g_free (pixels_out); return dst_pattern; }