Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_memory_leak_in_ws_server_example_v5.1' into …
Browse files Browse the repository at this point in the history
…'release/v5.1'

example: Fix memory leak in ws_echo_server when httpd_queue_work failed (backport v5.1)

See merge request espressif/esp-idf!23955
  • Loading branch information
mahavirj committed Jun 30, 2023
2 parents d93007b + 997f9dd commit 86eb786
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit 86eb786

Please sign in to comment.