From 83d12313486d133ecf17d8471de0335f6cdcd825 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 21 Nov 2018 10:51:21 +0100 Subject: [PATCH] core: in NMPolicy's _deactivate_if_active() safely iterate over active connections It's not clear that calling nm_manager_deactivate_connection() does not remove the active-connection entirely from the list. Just to be sure, use nm_manager_for_each_active_connection_safe() which allows deleting the current entry while iterating (all other modifications to the list are not allowed). --- src/nm-policy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nm-policy.c b/src/nm-policy.c index e4facf2614..00eaf4a94b 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -2404,12 +2404,12 @@ _deactivate_if_active (NMPolicy *self, NMSettingsConnection *connection) { NMPolicyPrivate *priv = NM_POLICY_GET_PRIVATE (self); NMActiveConnection *ac; - const CList *tmp_list; + const CList *tmp_list, *tmp_safe; GError *error = NULL; nm_assert (NM_IS_SETTINGS_CONNECTION (connection)); - nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { + nm_manager_for_each_active_connection_safe (priv->manager, ac, tmp_list, tmp_safe) { if ( nm_active_connection_get_settings_connection (ac) == connection && (nm_active_connection_get_state (ac) <= NM_ACTIVE_CONNECTION_STATE_ACTIVATED)) {