From cbe261caa24f9f58fd28cd20a811952068d7f8d2 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 3 Oct 2013 09:57:01 -0400 Subject: [PATCH] libnm: more valgrinding fixes --- libnm-glib/nm-client.c | 6 ++++-- libnm-glib/nm-device-generic.c | 1 + libnm-glib/nm-device.c | 13 +++++++++---- libnm-glib/nm-object.c | 4 +++- libnm-util/nm-setting-connection.c | 1 + libnm-util/nm-setting-vlan.c | 2 ++ 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libnm-glib/nm-client.c b/libnm-glib/nm-client.c index ddde49a62..44fb24dc7 100644 --- a/libnm-glib/nm-client.c +++ b/libnm-glib/nm-client.c @@ -501,7 +501,7 @@ static void recheck_pending_activations (NMClient *self, const char *failed_path, GError *error) { NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (self); - GSList *iter; + GSList *iter, *next; const GPtrArray *active_connections; gboolean found_in_active = FALSE; gboolean found_in_pending = FALSE; @@ -516,9 +516,11 @@ recheck_pending_activations (NMClient *self, const char *failed_path, GError *er * If the connection to activate doesn't make it to active_connections, * due to an error, we have to call the callback for failed_path. */ - for (iter = priv->pending_activations; iter; iter = g_slist_next (iter)) { + for (iter = priv->pending_activations; iter; iter = next) { ActivateInfo *info = iter->data; + next = g_slist_next (iter); + if (!found_in_pending && failed_path && g_strcmp0 (failed_path, info->active_path) == 0) { found_in_pending = TRUE; ainfo = info; diff --git a/libnm-glib/nm-device-generic.c b/libnm-glib/nm-device-generic.c index fb0b69342..f014e65d2 100644 --- a/libnm-glib/nm-device-generic.c +++ b/libnm-glib/nm-device-generic.c @@ -204,6 +204,7 @@ finalize (GObject *object) NMDeviceGenericPrivate *priv = NM_DEVICE_GENERIC_GET_PRIVATE (object); g_free (priv->hw_address); + g_free (priv->type_description); G_OBJECT_CLASS (nm_device_generic_parent_class)->finalize (object); } diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index c68b38dcb..f03d47cf7 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -226,6 +226,11 @@ device_state_change_reloaded (GObject *object, NMDevice *self = NM_DEVICE (object); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); StateChangeData *data = user_data; + NMDeviceState old_state = data->old_state; + NMDeviceState new_state = data->new_state; + NMDeviceStateReason reason = data->reason; + + g_slice_free (StateChangeData, data); _nm_object_reload_properties_finish (NM_OBJECT (object), result, NULL); @@ -234,17 +239,16 @@ device_state_change_reloaded (GObject *object, * they'll finish in the right order. In that case, only emit the signal * for the last one. */ - if (priv->last_seen_state != data->new_state) + if (priv->last_seen_state != new_state) return; /* Ensure that nm_device_get_state() will return the right value even if * we haven't processed the corresponding PropertiesChanged yet. */ - priv->state = data->new_state; + priv->state = new_state; g_signal_emit (self, signals[STATE_CHANGED], 0, - data->new_state, data->old_state, data->reason); - g_slice_free (StateChangeData, data); + new_state, old_state, reason); } static void @@ -384,6 +388,7 @@ finalize (GObject *object) g_free (priv->firmware_version); g_free (priv->product); g_free (priv->vendor); + g_free (priv->type_description); G_OBJECT_CLASS (nm_device_parent_class)->finalize (object); } diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index c69b0cae3..e13fbf31e 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -741,8 +741,10 @@ add_to_object_array_unique (GPtrArray *array, GObject *obj) if (obj != NULL) { for (i = 0; i < array->len; i++) { - if (g_ptr_array_index (array, i) == obj) + if (g_ptr_array_index (array, i) == obj) { + g_object_unref (obj); return; + } } g_ptr_array_add (array, obj); } diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index 630356cc4..266dbefc7 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -870,6 +870,7 @@ finalize (GObject *object) g_free (priv->master); g_free (priv->slave_type); g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free); + g_slist_free_full (priv->secondaries, g_free); G_OBJECT_CLASS (nm_setting_connection_parent_class)->finalize (object); } diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c index 256e16fa2..e56ccb4de 100644 --- a/libnm-util/nm-setting-vlan.c +++ b/libnm-util/nm-setting-vlan.c @@ -656,6 +656,8 @@ finalize (GObject *object) g_free (priv->parent); g_slist_free_full (priv->ingress_priority_map, g_free); g_slist_free_full (priv->egress_priority_map, g_free); + + G_OBJECT_CLASS (nm_setting_vlan_parent_class)->finalize (object); } static void