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.
This commit is contained in:
Dan Winship 2014-08-08 11:08:18 -04:00
parent 2ac34e437f
commit 58a66cc70b

View file

@ -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);