Skip to content

Commit

Permalink
Merge pull request #347 from AndrewTsao/patch-1
Browse files Browse the repository at this point in the history
forget to free req when tcp connect failed
  • Loading branch information
rphillips committed Sep 24, 2012
2 parents 6acab3a + 22cf366 commit fd94f2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/luv_tcp.c
Expand Up @@ -166,7 +166,9 @@ int luv_tcp_connect(lua_State* L) {
uv_connect_t* req = (uv_connect_t*)malloc(sizeof(uv_connect_t));

if (uv_tcp_connect(req, handle, address, luv_after_connect)) {
uv_err_t err = uv_last_error(luv_get_loop(L));
uv_err_t err;
free(req);
err = uv_last_error(luv_get_loop(L));
return luaL_error(L, "tcp_connect: %s", uv_strerror(err));
}

Expand All @@ -186,7 +188,9 @@ int luv_tcp_connect6(lua_State* L) {
uv_connect_t* req = (uv_connect_t*)malloc(sizeof(uv_connect_t));

if (uv_tcp_connect6(req, handle, address, luv_after_connect)) {
uv_err_t err = uv_last_error(luv_get_loop(L));
uv_err_t err;
free(req);
err = uv_last_error(luv_get_loop(L));
return luaL_error(L, "tcp_connect6: %s", uv_strerror(err));
}

Expand Down

0 comments on commit fd94f2c

Please sign in to comment.