diff options
-rw-r--r-- | src/bluetooth-adapter.c | 15 | ||||
-rw-r--r-- | src/bluetooth-map-client.c | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c index ce9fc4e..0f71324 100644 --- a/src/bluetooth-adapter.c +++ b/src/bluetooth-adapter.c @@ -3308,7 +3308,7 @@ int bt_adapter_le_get_scan_result_ibeacon_report(const bt_adapter_le_device_scan bt_adapter_le_packet_type_e pkt_type, bt_adapter_le_ibeacon_scan_result_info_s **ibeacon_info) { int manufacturer_id; - char *manufacturer_data; + char *manufacturer_data = NULL; int manufacturer_data_len; BT_CHECK_LE_SUPPORT(); @@ -3320,11 +3320,18 @@ int bt_adapter_le_get_scan_result_ibeacon_report(const bt_adapter_le_device_scan &manufacturer_data_len) != BT_ERROR_NONE) return BT_ERROR_NO_DATA; - if (manufacturer_data == NULL || manufacturer_data_len < 23) + if (manufacturer_data == NULL) return BT_ERROR_NO_DATA; - if (manufacturer_id != COMPANY_ID_APPLE) + if (manufacturer_data_len < 23) { + bt_adapter_free_manufacturer_data(manufacturer_data); return BT_ERROR_NO_DATA; + } + + if (manufacturer_id != COMPANY_ID_APPLE) { + bt_adapter_free_manufacturer_data(manufacturer_data); + return BT_ERROR_NO_DATA; + } *ibeacon_info = g_malloc0(sizeof(bt_adapter_le_ibeacon_scan_result_info_s)); @@ -3347,6 +3354,8 @@ int bt_adapter_le_get_scan_result_ibeacon_report(const bt_adapter_le_device_scan (*ibeacon_info)->measured_power = manufacturer_data[22]; + bt_adapter_free_manufacturer_data(manufacturer_data); + return BT_ERROR_NONE; /* LCOV_EXCL_STOP */ } diff --git a/src/bluetooth-map-client.c b/src/bluetooth-map-client.c index 9cc1cf8..a7e92dd 100644 --- a/src/bluetooth-map-client.c +++ b/src/bluetooth-map-client.c @@ -333,16 +333,16 @@ int bt_map_client_get_message(bt_map_client_session_info_h handle, bt_map_client_session_info_s* session = (bt_map_client_session_info_s*) handle; - bt_get_message_callback_data *data = g_malloc(sizeof(*data)); - data->target_file = target_file; - data->user_data = user_data; - int error_code = _bt_get_error_code(bluetooth_map_client_get_message(session, message_object, target_file, attachment)); if (error_code != BT_ERROR_NONE) { BT_ERR("bt_map_client_get_message %s(0x%08x)", _bt_convert_error_to_string(error_code), error_code); } else { + bt_get_message_callback_data *data = g_malloc(sizeof(*data)); + data->target_file = target_file; + data->user_data = user_data; + _bt_set_cb(BT_EVENT_MAP_CLIENT_GET_MESSAGE, callback, data); } |