[PATCH BlueZ] device: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux