[glib] Plug a mem leak



commit 1f49f3fa349a49bf17f6cb58d060173b7a448bf5
Author: Christian Persch <chpe gnome org>
Date:   Mon Aug 30 19:00:05 2010 +0200

    Plug a mem leak
    
    ... and use g_error_matches().
    
    ==29535== 1,360 (408 direct, 952 indirect) bytes in 17 blocks are definitely lost in loss record 1,252 of 1,264
    ==29535==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
    ==29535==    by 0x4057094: g_malloc (gmem.c:134)
    ==29535==    by 0x406F2D6: g_slice_alloc (gslice.c:836)
    ==29535==    by 0x406F31B: g_slice_alloc0 (gslice.c:848)
    ==29535==    by 0x403A751: g_error_new_valist (gerror.c:54)
    ==29535==    by 0x403AAD4: g_set_error (gerror.c:240)
    ==29535==    by 0x41C06C8: g_socket_send_message (gsocket.c:2967)
    ==29535==    by 0x421CB64: write_message_continue_writing (gdbusprivate.c:958)
    ==29535==    by 0x421CE2A: write_message_async (gdbusprivate.c:1049)
    ==29535==    by 0x421D4DD: maybe_write_next_message (gdbusprivate.c:1291)
    ==29535==    by 0x421D26B: message_written (gdbusprivate.c:1187)
    ==29535==    by 0x421D322: write_message_cb (gdbusprivate.c:1216)
    
    Bug #628345.

 gio/gdbusprivate.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 6d1a71d..91942a9 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -970,7 +970,7 @@ write_message_continue_writing (MessageToWriteData *data)
       if (bytes_written == -1)
         {
           /* Handle WOULD_BLOCK by waiting until there's room in the buffer */
-          if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_WOULD_BLOCK)
+          if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
             {
               GSource *source;
               source = g_socket_create_source (data->worker->socket,
@@ -982,6 +982,7 @@ write_message_continue_writing (MessageToWriteData *data)
                                      NULL); /* GDestroyNotify */
               g_source_attach (source, g_main_context_get_thread_default ());
               g_source_unref (source);
+              g_error_free (error);
               goto out;
             }
           g_simple_async_result_set_from_error (simple, error);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]