[telepathy-account-widgets] account-settings: Always take ownership of variant in ::set()
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [telepathy-account-widgets] account-settings: Always take ownership of variant in ::set()
- Date: Fri, 31 Jul 2015 19:01:16 +0000 (UTC)
commit ef1e65f32b03631b48b7d3deba4b7054274216d6
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Jul 30 09:55:31 2015 +0200
account-settings: Always take ownership of variant in ::set()
In one codepath, tpaw_account_settings_set() takes ownership of the
passed-in GVariant through g_variant_ref_sink, but in the other
codepath, ownership is left to the caller, which is unusual with
functions with GVariant parameters.
This commit unconditionnally calls g_variant_sink_ref() on the GVariant
arg rather than doing it in just one codepath, and then makes sure we
unref() the passed in GVariant when we don't want to keep it around.
This fixes a memory leak in tpaw_account_settings_set()
This fixes
==26855== 507 (240 direct, 267 indirect) bytes in 6 blocks are definitely lost in loss record 32,940 of 3
==26855== at 0x4A06C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==26855== by 0x8A120AC: g_malloc (gmem.c:97)
==26855== by 0x8A2B0F7: g_slice_alloc (gslice.c:1007)
==26855== by 0x8A52C0B: g_variant_alloc (gvariant-core.c:476)
==26855== by 0x8A52C9B: g_variant_new_from_bytes (gvariant-core.c:512)
==26855== by 0x8A4A60F: g_variant_new_from_trusted (gvariant.c:295)
==26855== by 0x8A4BAF6: g_variant_new_string (gvariant.c:1232)
==26855== by 0x4CBBE2E: account_widget_entry_changed_common (tpaw-account-widget.c:281)
==26855== by 0x4CBBED8: account_widget_entry_changed_cb (tpaw-account-widget.c:299)
==26855== by 0x87741EA: g_cclosure_marshal_VOID__VOID (gmarshal.c:875)
==26855== by 0x8771238: g_closure_invoke (gclosure.c:801)
==26855== by 0x878E070: signal_emit_unlocked_R (gsignal.c:3581)
==26855== by 0x878D3A7: g_signal_emit_valist (gsignal.c:3337)
==26855== by 0x878DA56: g_signal_emit_by_name (gsignal.c:3433)
==26855== by 0x73C0612: end_change (gtkentry.c:2928)
==26855== by 0x73C5F0D: gtk_entry_real_insert_text (gtkentry.c:5360)
==26855== by 0x7495B9A: _gtk_marshal_VOID__STRING_INT_POINTER (gtkmarshalers.c:7351)
==26855== by 0x87719A3: g_type_iface_meta_marshal (gclosure.c:1045)
https://bugzilla.gnome.org/show_bug.cgi?id=752938
tp-account-widgets/tpaw-account-settings.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/tp-account-widgets/tpaw-account-settings.c b/tp-account-widgets/tpaw-account-settings.c
index e0d2a12..541ef39 100644
--- a/tp-account-widgets/tpaw-account-settings.c
+++ b/tp-account-widgets/tpaw-account-settings.c
@@ -1027,16 +1027,18 @@ tpaw_account_settings_set (TpawAccountSettings *settings,
g_return_if_fail (param != NULL);
g_return_if_fail (v != NULL);
+ g_variant_ref_sink (v);
+
if (!tp_strdiff (param, "password") && settings->priv->supports_sasl &&
g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
{
g_free (settings->priv->password);
settings->priv->password = g_variant_dup_string (v, NULL);
+ g_variant_unref (v);
}
else
{
- g_hash_table_insert (settings->priv->parameters, g_strdup (param),
- g_variant_ref_sink (v));
+ g_hash_table_insert (settings->priv->parameters, g_strdup (param), v);
}
account_settings_remove_from_unset (settings, param);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]