mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
fix(protocomm): memory leak issue for session command0 failure case
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -172,19 +172,21 @@ static esp_err_t handle_session_command0(session_t *cur_session,
|
|||||||
out->payload_case = SEC2_PAYLOAD__PAYLOAD_SR0;
|
out->payload_case = SEC2_PAYLOAD__PAYLOAD_SR0;
|
||||||
out->sr0 = out_resp;
|
out->sr0 = out_resp;
|
||||||
|
|
||||||
resp->sec_ver = SEC_SCHEME_VERSION__SecScheme2;
|
|
||||||
resp->proto_case = SESSION_DATA__PROTO_SEC2;
|
|
||||||
resp->sec2 = out;
|
|
||||||
|
|
||||||
cur_session->username_len = in->sc0->client_username.len;
|
cur_session->username_len = in->sc0->client_username.len;
|
||||||
cur_session->username = malloc(cur_session->username_len);
|
cur_session->username = malloc(cur_session->username_len);
|
||||||
if (!cur_session->username) {
|
if (!cur_session->username) {
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory!");
|
ESP_LOGE(TAG, "Failed to allocate memory!");
|
||||||
esp_srp_free(cur_session->srp_hd);
|
esp_srp_free(cur_session->srp_hd);
|
||||||
|
free(out);
|
||||||
|
free(out_resp);
|
||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
memcpy(cur_session->username, in->sc0->client_username.data, in->sc0->client_username.len);
|
memcpy(cur_session->username, in->sc0->client_username.data, in->sc0->client_username.len);
|
||||||
|
|
||||||
|
resp->sec_ver = SEC_SCHEME_VERSION__SecScheme2;
|
||||||
|
resp->proto_case = SESSION_DATA__PROTO_SEC2;
|
||||||
|
resp->sec2 = out;
|
||||||
|
|
||||||
cur_session->state = SESSION_STATE_CMD1;
|
cur_session->state = SESSION_STATE_CMD1;
|
||||||
|
|
||||||
ESP_LOGD(TAG, "Session setup phase1 done");
|
ESP_LOGD(TAG, "Session setup phase1 done");
|
||||||
|
Reference in New Issue
Block a user