From: Wootak Jung Date: Wed, 2 Jan 2019 06:30:30 +0000 (+0900) Subject: Fix missing vcard response data X-Git-Tag: submit/tizen/20190108.053122~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=655ca6efdf5dfda88b9783225eea2dcef4bf6b7b;p=platform%2Fcore%2Fapi%2Fbluetooth.git Fix missing vcard response data Change-Id: Id4a3626271eabe522d1782e2744b00349d6a36fe --- diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index 941b5ef..3d23a02 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -2938,13 +2938,14 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us bt_pbap_vcard_list_t *vc_list = (bt_pbap_vcard_list_t *)(param->param_data); bt_pbap_vcard_info_s *vcard_info = NULL; - if (vc_list->length > 0) - vcard_info = g_malloc0(vc_list->length * sizeof(bt_pbap_vcard_info_s)); - BT_INFO("BLUETOOTH_PBAP_VCARD_LIST"); - for (i = 0; i < vc_list->length; i++) - vcard_info[i].contact_name = g_strdup(vc_list->vcards[i]); + if (vc_list->length > 0) { + vcard_info = g_malloc0(vc_list->length * sizeof(bt_pbap_vcard_info_s)); + for (i = 0; i < vc_list->length; i++) { + vcard_info[i].contact_name = g_strdup(vc_list->vcards[i]); + } + } _bt_unset_cb(BT_EVENT_PBAP_VCARD_LIST); _bt_convert_address_to_string(&device_addr, &vc_list->btaddr); @@ -2958,7 +2959,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us if (vcard_info != NULL) { for (i = 0; i < vc_list->length; i++) g_free((char *)vcard_info[i].contact_name); - free(vcard_info); + g_free(vcard_info); } break; } @@ -2980,13 +2981,18 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us break; } case BLUETOOTH_PBAP_PHONEBOOK_SEARCH: { + int i; bt_pbap_list_vcards_cb cb = bt_event_slot_container[event_index].callback; void *local_user_data = bt_event_slot_container[event_index].user_data; bt_pbap_phonebook_search_list_t *vc_list = (bt_pbap_phonebook_search_list_t *)(param->param_data); bt_pbap_vcard_info_s *vcard_info = NULL; - if (vc_list->length > 0) + if (vc_list->length > 0) { vcard_info = g_malloc0(vc_list->length * sizeof(bt_pbap_vcard_info_s)); + for (i = 0; i < vc_list->length; i++) { + vcard_info[i].contact_name = g_strdup(vc_list->vcards[i]); + } + } BT_INFO("BLUETOOTH_PBAP_PHONEBOOK_SEARCH"); @@ -2999,8 +3005,11 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us if (device_addr != NULL) free(device_addr); - g_free(vcard_info); - + if (vcard_info != NULL) { + for (i = 0; i < vc_list->length; i++) + g_free((char *)vcard_info[i].contact_name); + g_free(vcard_info); + } break; } case BLUETOOTH_EVENT_HF_CONNECTED: