summaryrefslogtreecommitdiff
path: root/xfconf
diff options
context:
space:
mode:
authorAli Abdallah <aliovx@gmail.com>2016-04-25 15:29:19 +0200
committerAli Abdallah <aliovx@gmail.com>2016-04-25 15:29:19 +0200
commitbae6bce6118b485f02d102de748cd2d9fe959ad9 (patch)
tree9d1f5233f8c77bd6245d40bd397493a9edd788c5 /xfconf
parent0546a8519dd5fa9fece07d3c1d5ca42a435ef593 (diff)
downloadxfconf-bae6bce6118b485f02d102de748cd2d9fe959ad9.tar.gz
Fix a couple of memory leaks, due to g_variant conversion floating
references.
Diffstat (limited to 'xfconf')
-rw-r--r--xfconf/xfconf-cache.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/xfconf/xfconf-cache.c b/xfconf/xfconf-cache.c
index 65dba64..491b99a 100644
--- a/xfconf/xfconf-cache.c
+++ b/xfconf/xfconf-cache.c
@@ -754,7 +754,7 @@ xfconf_cache_set(XfconfCache *cache,
const GValue *value,
GError **error)
{
- GVariant *variant = NULL;
+ GVariant *variant = NULL, *val = NULL;
GDBusProxy *proxy = _xfconf_get_gdbus_proxy();
XfconfCacheItem *item = NULL;
XfconfCacheOldItem *old_item = NULL;
@@ -820,31 +820,36 @@ xfconf_cache_set(XfconfCache *cache,
g_hash_table_insert(cache->old_properties, old_item->property, old_item);
}
- variant = g_variant_new_variant (xfconf_gvalue_to_gvariant (value));
-
- xfconf_exported_call_set_property ((XfconfExported *)proxy,
- cache->channel_name,
- property,
- variant,
- old_item->cancellable,
- (GAsyncReadyCallback) xfconf_cache_set_property_reply_handler,
- old_item);
-
- g_hash_table_insert(cache->pending_calls, old_item->cancellable, old_item);
+ val = xfconf_gvalue_to_gvariant (value);
+ if (val) {
+ variant = g_variant_new_variant (val);
+
+ xfconf_exported_call_set_property ((XfconfExported *)proxy,
+ cache->channel_name,
+ property,
+ variant,
+ old_item->cancellable,
+ (GAsyncReadyCallback) xfconf_cache_set_property_reply_handler,
+ old_item);
+
+ g_hash_table_insert(cache->pending_calls, old_item->cancellable, old_item);
+
+ if(item)
+ xfconf_cache_item_update(item, value);
+ else {
+ item = xfconf_cache_item_new(value, FALSE);
+ g_tree_insert(cache->properties, g_strdup(property), item);
+ }
+
+ xfconf_cache_mutex_unlock(cache);
- if(item)
- xfconf_cache_item_update(item, value);
- else {
- item = xfconf_cache_item_new(value, FALSE);
- g_tree_insert(cache->properties, g_strdup(property), item);
+ g_signal_emit(G_OBJECT(cache), signals[SIG_PROPERTY_CHANGED], 0,
+ cache->channel_name, property, value);
+
+ g_variant_unref (val);
+ return TRUE;
}
-
- xfconf_cache_mutex_unlock(cache);
-
- g_signal_emit(G_OBJECT(cache), signals[SIG_PROPERTY_CHANGED], 0,
- cache->channel_name, property, value);
-
- return TRUE;
+ return FALSE;
}
typedef struct