mirror of
https://github.com/espressif/esp-idf
synced 2025-03-12 18:49:08 -04:00
ble_mesh: fix ble mesh btc may caused memory leak
This commit is contained in:
parent
0f36dabcaf
commit
329388fa47
@ -126,6 +126,16 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_CFG_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_CFG_CLIENT_SET_STATE_EVT:
|
||||
@ -211,14 +221,6 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_CFG_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -165,6 +165,16 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
|
||||
@ -277,14 +287,6 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -127,6 +127,16 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
|
||||
@ -167,14 +177,6 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -121,6 +121,16 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
|
||||
@ -147,14 +157,6 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -256,6 +256,16 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
|
||||
@ -367,14 +377,6 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -121,6 +121,16 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
|
||||
@ -148,14 +158,6 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user