From 941dbc5f3b56fea087a3b88bc73cf2776c02d4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 18 Jun 2025 17:29:18 +0200 Subject: [PATCH] device: Fix memory leak This frees the LastUsedBearer string to avoid memory leak: Direct leak of 12 byte(s) in 2 object(s) allocated from: #0 0x7ccf538fd9c7 in malloc ../../../../src/libsanitizer/asan/ asan_malloc_linux.cpp:69 #1 0x7ccf53665b09 in g_malloc (/lib/x86_64-linux-gnu/ libglib-2.0.so.0+0x62b09) #2 0x7ccf53659b90 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x56b90) #3 0x7ccf53659cd4 in g_key_file_get_string (/lib/x86_64-linux-gnu/ libglib-2.0.so.0+0x56cd4) #4 0x5c8c691f2811 in load_info src/device.c:4225 --- src/device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 902c4aa44..e4d5d79ee 100644 --- a/src/device.c +++ b/src/device.c @@ -4224,10 +4224,12 @@ static void load_info(struct btd_device *device, const char *local, /* Load last used bearer */ str = g_key_file_get_string(key_file, "General", "LastUsedBearer", NULL); - if (str) + if (str) { device_update_last_used(device, !strcmp(str, "le") ? device->bdaddr_type : BDADDR_BREDR); + g_free(str); + } } next: -- 2.47.3