[glib] Plug a mem leak
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Plug a mem leak
- Date: Fri, 14 May 2010 22:10:15 +0000 (UTC)
commit 0a7c0ac74bd55d06265e9441c5728119adc254ab
Author: Christian Persch <chpe gnome org>
Date: Fri May 14 18:08:29 2010 -0400
Plug a mem leak
This code leaked the return value of g_variant_get_child_value();
use g_variant_get() instead and free the iter when done.
gio/gdbusproxy.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index 53ef06e..51cb5f2 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -797,8 +797,9 @@ static void
process_get_all_reply (GDBusProxy *proxy,
GVariant *result)
{
- GVariantIter iter;
- GVariant *item;
+ GVariantIter *iter;
+ gchar *key;
+ GVariant *value;
if (strcmp (g_variant_get_type_string (result), "(a{sv})") != 0)
{
@@ -807,22 +808,17 @@ process_get_all_reply (GDBusProxy *proxy,
goto out;
}
- g_variant_iter_init (&iter, g_variant_get_child_value (result, 0));
- while ((item = g_variant_iter_next_value (&iter)) != NULL)
+ g_variant_get (result, "(a{sv})", &iter);
+ while (g_variant_iter_next (iter, "{sv}", &key, &value))
{
- gchar *key;
- GVariant *value;
-
- g_variant_get (item,
- "{sv}",
- &key,
- &value);
//g_print ("got %s -> %s\n", key, g_variant_markup_print (value, FALSE, 0, 0));
g_hash_table_insert (proxy->priv->properties,
- key,
- value); /* steals value */
+ key, /* adopts string */
+ value); /* adopts value */
}
+ g_variant_iter_free (iter);
+
out:
;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]