Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: fix memory leak in udp.c
Browse files Browse the repository at this point in the history
Some memory was leaked when the uv_udp_t handle was closed when there were
in-flight send requests with a heap allocated buffer list.

That doesn't happen much in practice. In the common case (writing < 5 buffers),
the buffer list is stored inside the uv_udp_send_t structure, not allocated on
the heap.
  • Loading branch information
bnoordhuis committed Aug 25, 2012
1 parent 0ac2fdc commit ad7b48a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/unix/udp.c
Expand Up @@ -86,6 +86,10 @@ void uv__udp_finish_close(uv_udp_t* handle) {
req = ngx_queue_data(q, uv_udp_send_t, queue);
uv__req_unregister(handle->loop, req);

if (req->bufs != req->bufsml)
free(req->bufs);
req->bufs = NULL;

if (req->send_cb) {
/* FIXME proper error code like UV_EABORTED */
uv__set_artificial_error(handle->loop, UV_EINTR);
Expand Down Expand Up @@ -171,6 +175,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {

if (req->bufs != req->bufsml)
free(req->bufs);
req->bufs = NULL;

if (req->send_cb == NULL)
continue;
Expand Down

0 comments on commit ad7b48a

Please sign in to comment.