Fix crash issue when create bond fails 20/317520/1
authorWootak Jung <wootak.jung@samsung.com>
Fri, 3 Jan 2025 03:16:46 +0000 (12:16 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Fri, 3 Jan 2025 04:52:10 +0000 (13:52 +0900)
Fix issue where bonded_device was null when create bond failed, causing
a crash when passed to C#.

Change-Id: I82d4d4f8c51ebec90e7f89adb94093dec9bda85d
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/bluetooth-common.c

index f3047225555249c909f38045330b86291a106b5b..63f8c353bda7c33ce94da4a37e921fcd55720232 100644 (file)
@@ -1695,6 +1695,12 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
                BT_INFO("bt_device_bond_created_cb() will be called");
                _bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data));
 
+               if (bonded_device == NULL) {
+                       bonded_device = (bt_device_info_s *)malloc(sizeof(bt_device_info_s));
+                       if (bonded_device != NULL)
+                               memset(bonded_device, 0x00, sizeof(bt_device_info_s));
+               }
+
                ((bt_device_bond_created_cb)bt_event_slot_container[event_index].callback)
                    (_bt_get_error_code(param->result), bonded_device, bt_event_slot_container[event_index].user_data);
                _bt_free_bt_device_info_s(bonded_device);