st-private_correct_fix_memory_leak.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From c975740f9228b2c53d79ac08ad704fca5f1c5b6e Mon Sep 17 00:00:00 2001
  2. From: Colin Walters <walters@verbum.org>
  3. Date: Wed, 11 May 2011 15:21:18 +0000
  4. Subject: st-private: Correct fix for memory leak
  5. The previous fix in 72f9f482d was wrong; we need to keep around
  6. the buffer until cairo is done with the pattern.
  7. https://bugzilla.gnome.org/show_bug.cgi?id=649497
  8. ---
  9. diff --git a/src/st/st-private.c b/src/st/st-private.c
  10. index 51798a1..21ca09a 100644
  11. --- a/src/st/st-private.c
  12. +++ b/src/st/st-private.c
  13. @@ -667,6 +667,7 @@ cairo_pattern_t *
  14. _st_create_shadow_cairo_pattern (StShadow *shadow_spec,
  15. cairo_pattern_t *src_pattern)
  16. {
  17. + static cairo_user_data_key_t shadow_pattern_user_data;
  18. cairo_t *cr;
  19. cairo_surface_t *src_surface;
  20. cairo_surface_t *surface_in;
  21. @@ -728,6 +729,8 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec,
  22. width_out,
  23. height_out,
  24. rowstride_out);
  25. + cairo_surface_set_user_data (surface_out, &shadow_pattern_user_data,
  26. + pixels_out, (cairo_destroy_func_t) g_free);
  27. dst_pattern = cairo_pattern_create_for_surface (surface_out);
  28. cairo_surface_destroy (surface_out);
  29. @@ -745,8 +748,7 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec,
  30. (width_out - width_in) / 2.0,
  31. (height_out - height_in) / 2.0);
  32. cairo_pattern_set_matrix (dst_pattern, &shadow_matrix);
  33. -
  34. - goto out;
  35. + return dst_pattern;
  36. }
  37. /* Read all the code from the cairo_pattern_set_matrix call
  38. @@ -784,8 +786,6 @@ _st_create_shadow_cairo_pattern (StShadow *shadow_spec,
  39. cairo_pattern_set_matrix (dst_pattern, &shadow_matrix);
  40. - out:
  41. - g_free (pixels_out);
  42. return dst_pattern;
  43. }
  44. --
  45. cgit v0.9