From: DoHyun Pyun Date: Mon, 24 Feb 2020 05:29:17 +0000 (+0900) Subject: Fix the crash in the MTU changed event X-Git-Tag: submit/tizen/20200226.220348^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F225705%2F1;p=platform%2Fcore%2Fapi%2Fbluetooth.git Fix the crash in the MTU changed event Change-Id: I0b8d7c769b4845f592f5dc62066dd22af81c8120 Signed-off-by: DoHyun Pyun --- diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 9b22f14..78161ec 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -764,6 +764,8 @@ static void __bt_free_bt_device_sdp_info_s(bt_device_sdp_info_s *sdp_info) static int __bt_get_bt_gatt_client_att_mtu_info_s(bt_gatt_client_att_mtu_info_s **dest, bluetooth_le_att_mtu_info_t *source) { + BT_CHECK_INPUT_PARAMETER(source); + *dest = (bt_gatt_client_att_mtu_info_s *)g_malloc0(sizeof(bt_gatt_client_att_mtu_info_s)); if (_bt_convert_address_to_string(&((*dest)->remote_address), &(source->device_address)) != BT_ERROR_NONE) { @@ -781,6 +783,8 @@ static int __bt_get_bt_gatt_client_att_mtu_info_s(bt_gatt_client_att_mtu_info_s static int __bt_get_bt_gatt_server_att_mtu_info_s(bt_gatt_server_att_mtu_info_s **dest, bluetooth_le_att_mtu_info_t *source) { + BT_CHECK_INPUT_PARAMETER(source); + *dest = (bt_gatt_server_att_mtu_info_s *)g_malloc0(sizeof(bt_gatt_server_att_mtu_info_s)); if (_bt_convert_address_to_string(&((*dest)->remote_address), &(source->device_address)) != BT_ERROR_NONE) { @@ -3001,7 +3005,15 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_gatt_client_s *client = NULL; BT_INFO("BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED"); - __bt_get_bt_gatt_client_att_mtu_info_s(&mtu_info, (bluetooth_le_att_mtu_info_t *)(param->param_data)); + + if (__bt_get_bt_gatt_client_att_mtu_info_s(&mtu_info, + (bluetooth_le_att_mtu_info_t *)(param->param_data)) != BT_ERROR_NONE) { + BT_ERR("Fail to get MTU info"); + break; + } + + if (mtu_info == NULL) + break; client = _bt_gatt_get_client(mtu_info->remote_address); @@ -3032,7 +3044,14 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us server = (bt_gatt_server_s *)server_list->data; - __bt_get_bt_gatt_server_att_mtu_info_s(&mtu_info, (bluetooth_le_att_mtu_info_t *)(param->param_data)); + if (__bt_get_bt_gatt_server_att_mtu_info_s(&mtu_info, + (bluetooth_le_att_mtu_info_t *)(param->param_data)) != BT_ERROR_NONE) { + BT_ERR("Fail to get MTU info"); + break; + } + + if (mtu_info == NULL) + break; if (server && server->att_mtu_changed_cb) server->att_mtu_changed_cb(server,