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
This commit is contained in:
Marco Trevisan (Treviño)
2019-07-21 17:01:43 +02:00
committed by Thomas Haller
parent b8e9a62f2a
commit b621aba5c2

View File

@@ -1840,14 +1840,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))