From 833e126cf8beb7db8ea319606557d0fb963d5f7f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 5 Nov 2015 16:19:01 +0100 Subject: [PATCH] device: avoid removing a list element while iterating it --- src/devices/nm-device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e2adf86799..bc10379890 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -8559,12 +8559,13 @@ gboolean nm_device_remove_pending_action (NMDevice *self, const char *action, gboolean assert_is_pending) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - GSList *iter; + GSList *iter, *next; guint count = 0; g_return_val_if_fail (action, FALSE); - for (iter = priv->pending_actions; iter; iter = iter->next) { + for (iter = priv->pending_actions; iter; iter = next) { + next = iter->next; if (!strcmp (action, iter->data)) { _LOGD (LOGD_DEVICE, "remove_pending_action (%d): '%s'", count + g_slist_length (iter->next), /* length excluding 'iter' */