From 5ae8f19e8d398d45dbbaf2ed20ea1f05d1621c93 Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Fri, 3 Jan 2025 12:16:46 +0900 Subject: [PATCH] Fix crash issue when create bond fails 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 --- src/bluetooth-common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index f304722..63f8c35 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -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); -- 2.34.1