Skip to content

Commit

Permalink
forget to free req when tcp connect failed
Browse files Browse the repository at this point in the history
should we free the req when connect failed?
  • Loading branch information
AndrewTsao committed Sep 22, 2012
1 parent 6acab3a commit 22cf366
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 22cf366

Please sign in to comment.