[cairo] [PATCH] Fix Analysis Surface Memleak

Henning Noren henning.noren.402 at student.lu.se
Thu Apr 27 13:40:02 PDT 2006


On Thu, 2006-04-27 at 06:03 -0700, Carl Worth wrote:
> So I've gone ahead and committed what's below. Does that help with the
> specific problem you were looking at, or is there some other
> reference-counting problem here?
> 

Yes, that fixes the big memory-leak.
How about the second leak?

We leak 16 bytes when calling _cairo_ps_surface_finish by never freeing
the closure allocated in _word_wrap_stream_create on line 783 in
cairo-ps-surface.c. 

Sincerely
Henning

PS. Sorry for the extra private mail Carl. That was meant to be sent to
the list but I noticed the patch was garbled by my mail-client so I
resent it correctly.

---

 src/cairo-ps-surface.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

5692f9c4aafdf2a6fb3b0c5fa9b9b1a167ba0436
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 *
--
1.3.0



More information about the cairo mailing list