From 86456cf9a5f899d2a637fa8d0251f69e01922a44 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 2 Feb 2015 15:19:43 +0200 Subject: [PATCH] shared/gatt-client: Fix memory leak The following leak can be observed when bluetoothd is terminated while connected: 208 (128 direct, 80 indirect) bytes in 2 blocks are definitely lost in loss record 204 of 242 at 0x4C2B946: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x4CE112: bt_gatt_client_register_notify (gatt-client.c:2557) by 0x4999F0: characteristic_start_notify (gatt-client.c:1181) by 0x4C03FB: process_message.isra.3 (object.c:259) by 0x4C0C42: generic_message (object.c:1070) by 0x518C5CE: ??? (in /usr/lib64/libdbus-1.so.3.8.10) by 0x517E193: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.8.10) by 0x4BB38F: message_dispatch (mainloop.c:72) by 0x4E7EAEA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7EE87: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x4E7F1B1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.1) by 0x40BACF: main (main.c:631) --- src/shared/gatt-client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index ccc28db5c..09eb20a0a 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -1433,7 +1433,10 @@ static void complete_unregister_notify(void *data) return; } - notify_data_write_ccc(notify_data, false, disable_ccc_callback); + if (notify_data_write_ccc(notify_data, false, disable_ccc_callback)) + return; + + notify_data_unref(notify_data); } static void notify_handler(void *data, void *user_data) -- 2.47.3