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.
This commit is contained in:
Christian Persch 2010-08-30 19:00:05 +02:00 committed by Matthias Clasen
parent c75429d0a0
commit 1f49f3fa34

View File

@ -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);