device: free temporary typename with iface variable

To create a disambiguated name for some Bluetooth devices we use its type name
with iface, however this value is allocated but never free'd when passed to
g_strdup_printf.

So use instead a temporary variable and free it once done.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/208

Fixes: 8bbda5cdff
(cherry picked from commit b621aba5c2)
(cherry picked from commit 64ed96fb5f)
(cherry picked from commit 6156720c0d)
(cherry picked from commit f66040cc16)
This commit is contained in:
Marco Trevisan (Treviño) 2019-07-21 17:01:43 +02:00 committed by Thomas Haller
parent cacb80e567
commit 35a31b7910

View file

@ -1756,14 +1756,15 @@ nm_device_disambiguate_names (NMDevice **devices,
for (i = 0; i < num_devices; i++) {
if (duplicates[i] && NM_IS_DEVICE_BT (devices[i])) {
const char *devname = nm_device_bt_get_name (NM_DEVICE_BT (devices[i]));
char *name;
if (!devname)
continue;
g_free (names[i]);
names[i] = g_strdup_printf ("%s (%s)",
get_device_type_name_with_iface (devices[i]),
devname);
name = get_device_type_name_with_iface (devices[i]);
names[i] = g_strdup_printf ("%s (%s)", name, devname);
g_free (name);
}
}
if (!find_duplicates (names, duplicates, num_devices))