Plug mem leak in g_dbus_address_get_stream_sync
[platform/upstream/glib.git] / gio / gdbusaddress.c
index 2c1041e..5d8fc9c 100644 (file)
@@ -1,6 +1,6 @@
 /* GDBus - GLib D-Bus Library
  *
- * Copyright (C) 2008-2009 Red Hat, Inc.
+ * Copyright (C) 2008-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,8 +23,7 @@
 #include "config.h"
 
 #include <stdlib.h>
-
-#include <glib/gi18n.h>
+#include <string.h>
 
 #include "gdbusutils.h"
 #include "gdbusaddress.h"
 #include <gio/gunixsocketaddress.h>
 #endif
 
+#include "glibintl.h"
+#include "gioalias.h"
+
 /**
  * SECTION:gdbusaddress
  * @title: D-Bus Addresses
  * @short_description: D-Bus connection endpoints
  * @include: gio/gio.h
  *
- * Routines for working with D-Bus addresses.
+ * Routines for working with D-Bus addresses. A D-Bus address is a string
+ * like "unix:tmpdir=/tmp/my-app-name". The exact format of addresses
+ * is explained in detail in the <link linkend="http://dbus.freedesktop.org/doc/dbus-specification.html&num;addresses">D-Bus specification</link>.
  */
 
 /* ---------------------------------------------------------------------------------------------------- */
@@ -392,10 +396,10 @@ g_dbus_is_supported_address (const gchar  *string,
 }
 
 gboolean
-_g_dbus_address_parse_entry (const gchar   *address_entry,
-                             gchar        **out_transport_name,
-                             GHashTable   **out_key_value_pairs,
-                             GError       **error)
+_g_dbus_address_parse_entry (const gchar  *address_entry,
+                             gchar       **out_transport_name,
+                             GHashTable  **out_key_value_pairs,
+                             GError      **error)
 {
   gboolean ret;
   GHashTable *key_value_pairs;
@@ -481,11 +485,11 @@ out:
  * making libgio link to libX11...
  */
 static GIOStream *
-g_dbus_address_connect (const gchar    *address_entry,
-                        const gchar    *transport_name,
-                        GHashTable     *key_value_pairs,
-                        GCancellable   *cancellable,
-                        GError        **error)
+g_dbus_address_connect (const gchar   *address_entry,
+                        const gchar   *transport_name,
+                        GHashTable    *key_value_pairs,
+                        GCancellable  *cancellable,
+                        GError       **error)
 {
   GIOStream *ret;
   GSocketConnectable *connectable;
@@ -665,10 +669,10 @@ g_dbus_address_connect (const gchar    *address_entry,
 }
 
 static GIOStream *
-g_dbus_address_try_connect_one (const gchar         *address_entry,
-                                gchar              **out_guid,
-                                GCancellable        *cancellable,
-                                GError             **error)
+g_dbus_address_try_connect_one (const gchar   *address_entry,
+                                gchar        **out_guid,
+                                GCancellable  *cancellable,
+                                GError       **error)
 {
   GIOStream *ret;
   GHashTable *key_value_pairs;
@@ -852,10 +856,10 @@ g_dbus_address_get_stream_finish (GAsyncResult        *res,
  * Since: 2.26
  */
 GIOStream *
-g_dbus_address_get_stream_sync (const gchar         *address,
-                                gchar              **out_guid,
-                                GCancellable        *cancellable,
-                                GError             **error)
+g_dbus_address_get_stream_sync (const gchar   *address,
+                                gchar        **out_guid,
+                                GCancellable  *cancellable,
+                                GError       **error)
 {
   GIOStream *ret;
   gchar **addr_array;
@@ -903,6 +907,8 @@ g_dbus_address_get_stream_sync (const gchar         *address,
       g_assert (last_error != NULL);
       g_propagate_error (error, last_error);
     }
+
+  g_strfreev (addr_array);
   return ret;
 }
 
@@ -1014,3 +1020,6 @@ g_dbus_address_get_for_bus_sync (GBusType       bus_type,
  out:
   return ret;
 }
+
+#define __G_DBUS_ADDRESS_C__
+#include "gioaliasdef.c"