[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Memory leaks in glib bindings
From:       Ross Burton <ross () burtonini ! com>
Date:       2005-06-20 11:18:26
Message-ID: 1119266306.3035.11.camel () localhost ! localdomain
[Download RAW message or body]

Hi,

Attached is a patch to fix a few memory leaks in the GLib bindings.

Thanks,
Ross
-- 
Ross Burton                                 mail: ross@burtonini.com
                                          jabber: ross@burtonini.com
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF


["dbus-memleak.diff" (dbus-memleak.diff)]

Index: glib/dbus-gobject.c
===================================================================
--- glib/dbus-gobject.c	(revision 194)
+++ glib/dbus-gobject.c	(working copy)
@@ -1247,6 +1247,8 @@
 
       g_closure_add_finalize_notifier (closure, NULL,
 				       dbus_g_signal_closure_finalize);
+
+      g_free (s);
     }
 }
 
@@ -1562,6 +1564,7 @@
   va_list args;
   char *out_sig;
   GArray *argsig;
+  GValueArray *values;
   guint i;
 
   reply = dbus_message_new_method_return (dbus_g_message_get_message (context->message));
@@ -1570,20 +1573,21 @@
 
   dbus_message_iter_init_append (reply, &iter);
 
+  values = g_value_array_new (0);
   va_start (args, context);
   for (i = 0; i < argsig->len; i++)
     {
-      GValue value = {0,};
       char *error;
-      g_value_init (&value, g_array_index (argsig, GType, i));
+      g_value_array_prepend (values, NULL);
+      g_value_init (&values->values[0], g_array_index (argsig, GType, i));
       error = NULL;
-      G_VALUE_COLLECT (&value, args, 0, &error);
+      G_VALUE_COLLECT (&values->values[0], args, 0, &error);
       if (error)
 	{
 	  g_warning(error);
 	  g_free (error);
 	}
-      dbus_gvalue_marshal (&iter, &value);
+      dbus_gvalue_marshal (&iter, &values->values[0]);
     }
   va_end (args);
 
@@ -1592,7 +1596,9 @@
 
   dbus_g_connection_unref (context->connection);
   dbus_g_message_unref (context->message);
+  g_value_array_free (values);
   g_free (context);
+  g_free (out_sig);
 }
 
 /**


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic