From a177f443e0d651e88b28909bb3f586a07f46a275 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 15 Jan 2015 10:56:02 -0500 Subject: [PATCH] libnm-core: fix a leak in _nm_setting_new_from_dbus() (cherry picked from commit bbbbca27787079ab028664f49f7bd1f3a3cad626) --- libnm-core/nm-setting.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c index 037baa6b58..48317fc7c6 100644 --- a/libnm-core/nm-setting.c +++ b/libnm-core/nm-setting.c @@ -796,7 +796,12 @@ _nm_setting_new_from_dbus (GType setting_type, properties = nm_setting_class_get_properties (class, &n_properties); for (i = 0; i < n_properties; i++) { const NMSettingProperty *property = &properties[i]; - GVariant *value = g_variant_lookup_value (setting_dict, property->name, NULL); + GVariant *value; + + if (property->param_spec && !(property->param_spec->flags & G_PARAM_WRITABLE)) + continue; + + value = g_variant_lookup_value (setting_dict, property->name, NULL); if (value && property->set_func) { property->set_func (setting, @@ -810,9 +815,6 @@ _nm_setting_new_from_dbus (GType setting_type, } else if (value && property->param_spec) { GValue object_value = { 0, }; - if (!(property->param_spec->flags & G_PARAM_WRITABLE)) - continue; - g_value_init (&object_value, property->param_spec->value_type); set_property_from_dbus (property, value, &object_value); g_object_set_property (G_OBJECT (setting), property->param_spec->name, &object_value);