From 58a66cc70ba73cf1a0fce1583277962a38eef2dd Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 8 Aug 2014 11:08:18 -0400 Subject: [PATCH] core: fix a warning and a leak For devices where we don't set the hardware address at construct time, the first call to nm_device_update_hw_address() was hitting a return-if-fail. Also, when updating the hardware address, we were leaking the old value. --- src/devices/nm-device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 277c10ad3a..99c969370d 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6917,7 +6917,8 @@ nm_device_update_hw_address (NMDevice *self) hwaddr = nm_platform_link_get_address (ifindex, &hwaddrlen); g_assert (hwaddrlen <= sizeof (priv->hw_addr)); if (hwaddrlen) { - if (!nm_utils_hwaddr_matches (priv->hw_addr, -1, hwaddr, hwaddrlen)) { + if (!priv->hw_addr || !nm_utils_hwaddr_matches (priv->hw_addr, -1, hwaddr, hwaddrlen)) { + g_free (priv->hw_addr); priv->hw_addr = nm_utils_hwaddr_ntoa (hwaddr, hwaddrlen); _LOGD (LOGD_HW | LOGD_DEVICE, "hardware address now %s", priv->hw_addr);