diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 289431ed61..99a0543ee7 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -2804,7 +2804,7 @@ void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 p_msg->is_scan_rsp = is_scan_rsp; p_msg->instance = instance; p_msg->length = length; - p_msg->data = (UINT8 *)(p_msg + 1); + p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL; if (data) { memcpy(p_msg->data, data, length); } @@ -2894,6 +2894,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, p_msg->length = length; p_msg->data = (UINT8 *)(p_msg + 1); memcpy(p_msg->data, data, length); + p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL; //start sent the msg to the bta system control moudle bta_sys_sendmsg(p_msg); } else { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 292d0ab237..09969ef97f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -1082,7 +1082,7 @@ static tBTM_STATUS btm_ble_ext_adv_params_validate(tBTM_BLE_GAP_EXT_ADV_PARAMS * static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len, UINT8 *data) { - if (!data) { + if (data == NULL && len > 0) { BTM_TRACE_ERROR("%s, the extend adv data is NULL. line %d", __func__, __LINE__); return BTM_ILLEGAL_VALUE; } diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 8aaab5ea2a..2b82203032 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -1273,17 +1273,16 @@ UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle, UINT8_TO_STREAM(pp, operation); UINT8_TO_STREAM(pp, fragment_prefrence); - if (p_data != NULL && data_len > 0) { - if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) { - data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA; - } - - UINT8_TO_STREAM (pp, data_len); - - ARRAY_TO_STREAM (pp, p_data, data_len); - } else { - return FALSE; + if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) { + data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA; } + + UINT8_TO_STREAM (pp, data_len); + + if (p_data != NULL && data_len > 0){ + ARRAY_TO_STREAM (pp, p_data, data_len); + } + uint8_t status = btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p); return status; @@ -1309,16 +1308,13 @@ UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle, memset(pp, 0, data_len); + if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) { + data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA; + } + + UINT8_TO_STREAM (pp, data_len); if (p_data != NULL && data_len > 0) { - if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) { - data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA; - } - - UINT8_TO_STREAM (pp, data_len); - ARRAY_TO_STREAM (pp, p_data, data_len); - } else { - return FALSE; } return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p); @@ -1455,16 +1451,14 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle, //memset(pp, 0, len); + if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) { + len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA; + } + + UINT8_TO_STREAM (pp, len); + if (p_data != NULL && len > 0) { - if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) { - len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA; - } - - UINT8_TO_STREAM (pp, len); - ARRAY_TO_STREAM (pp, p_data, len); - } else { - return FALSE; } return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);