[cairo] [PATCH] We need to close the closure.

Henning Noren henning.noren.402 at student.lu.se
Thu Apr 27 15:53:35 PDT 2006


Fixes leak of 16 bytes when calling _cairo_ps_surface_finish by never freeing 
the closure allocated in _word_wrap_stream_create.

---

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index f84a57a..31498a8 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -762,6 +762,19 @@ _word_wrap_stream_write (void                      *closure
     return _cairo_output_stream_get_status (stream->output);
 }
 
+static cairo_status_t
+_word_wrap_stream_close (void *closure)
+{
+    cairo_status_t status;
+    word_wrap_stream_t *stream = closure;
+
+    status = _cairo_output_stream_get_status (stream->output);
+
+    free (stream);
+
+    return status;
+}
+
 static cairo_output_stream_t *
 _word_wrap_stream_create (cairo_output_stream_t *output, int max_column)
 {
@@ -777,7 +790,7 @@ _word_wrap_stream_create (cairo_output_s
     stream->last_write_was_space = FALSE;
 
     return _cairo_output_stream_create (_word_wrap_stream_write,
-                                       NULL, stream);
+                                       _word_wrap_stream_close, stream);
 }
 
 static cairo_surface_t *




More information about the cairo mailing list