From 4ca885f5e3db46ebf0ed283f99ecde4378630a5b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 15 May 2013 14:39:16 -0500 Subject: [PATCH] core: fix list manipulation when removing multiple slaves nm_device_release_one_slave() may change the list head, but the for loop in nm_device_master_release_slaves() can't handle that. Use a while loop instead. --- src/devices/nm-device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6373c50778..724c292bad 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1121,12 +1121,12 @@ static void nm_device_master_release_slaves (NMDevice *self, gboolean failed) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - GSList *iter; - for (iter = priv->slaves; iter; iter = g_slist_next (iter)) - nm_device_release_one_slave (self, ((SlaveInfo *) iter->data)->slave, failed); - g_slist_free (priv->slaves); - priv->slaves = NULL; + while (priv->slaves) { + SlaveInfo *info = priv->slaves->data; + + nm_device_release_one_slave (self, info->slave, failed); + } }