Fix bt-service crash issue in testhub 69/232469/1
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 5 May 2020 22:48:20 +0000 (07:48 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 5 May 2020 22:48:20 +0000 (07:48 +0900)
Double free problem is occured into le scanner app termination
function. So this patchset adds the condition to fix it.

Change-Id: Ie76ed72ce6333bd5a0aea84dd9756b7eb4edb042
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c

index 6be2303..5f146f3 100644 (file)
@@ -2136,14 +2136,16 @@ void _bt_check_le_scanner_app_termination(const char *sender)
        if (!scanner)
                return;
 
-       if (scanner->is_scanning)
-               _bt_stop_le_scan(sender);
-
        _bt_bm_remove_scan_app(SCAN_LE, scanner->uid, scanner->pid);
 
+       if (scanner->is_scanning) {
+               /* Free 'scanner' into the function */
+               if (_bt_stop_le_scan(sender) != BLUETOOTH_ERROR_NOT_IN_OPERATION)
+                       return;
+       }
+
        scanner_list = g_slist_remove(scanner_list, scanner);
-       g_free(scanner->sender);
-       g_free(scanner);
+       __bt_free_le_scanner(scanner);
 }
 
 int _bt_service_le_init(void)