mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
example: Fix memory leak in ws_echo_server when httpd_queue_work failed
Closes https://github.com/espressif/esp-idf/issues/11507
This commit is contained in:
parent
6ad6fb9755
commit
997f9dd183
@ -55,9 +55,16 @@ static void ws_async_send(void *arg)
|
||||
static esp_err_t trigger_async_send(httpd_handle_t handle, httpd_req_t *req)
|
||||
{
|
||||
struct async_resp_arg *resp_arg = malloc(sizeof(struct async_resp_arg));
|
||||
if (resp_arg == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
resp_arg->hd = req->handle;
|
||||
resp_arg->fd = httpd_req_to_sockfd(req);
|
||||
return httpd_queue_work(handle, ws_async_send, resp_arg);
|
||||
esp_err_t ret = httpd_queue_work(handle, ws_async_send, resp_arg);
|
||||
if (ret != ESP_OK) {
|
||||
free(resp_arg);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user