From 35a31b7910059f0be4c0bde06dc75e6c667b6477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sun, 21 Jul 2019 17:01:43 +0200 Subject: [PATCH] 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: 8bbda5cdff0f7f04d3b5863edfdba335dab4c7f8 (cherry picked from commit b621aba5c213734d6bf672340efea8576d026ccc) (cherry picked from commit 64ed96fb5f82897a447d212c54a007ddaf51551c) (cherry picked from commit 6156720c0db26a888c5e84e879b010ec5e6cb3f0) (cherry picked from commit f66040cc16b7a6aeb64588de297be87a9a3ba908) --- libnm/nm-device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libnm/nm-device.c b/libnm/nm-device.c index d496139962..da8d206328 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -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))