Skip to content

Commit

Permalink
Fix error case where a socket opened by init_conn() was not properly …
Browse files Browse the repository at this point in the history
…closed

on error.  This leak was identified by Coverity.
  • Loading branch information
tjsaunders committed Oct 11, 2014
1 parent 55d35c0 commit 5ac5945
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/inet.c
Expand Up @@ -286,7 +286,6 @@ static conn_t *init_conn(pool *p, int fd, pr_netaddr_t *bind_addr,
}

if (fd == -1) {

/* On failure, destroy the connection and return NULL. */
if (reporting) {
pr_log_pri(PR_LOG_WARNING,
Expand Down Expand Up @@ -315,7 +314,12 @@ static conn_t *init_conn(pool *p, int fd, pr_netaddr_t *bind_addr,

memset(&na, 0, sizeof(na));
if (pr_netaddr_set_family(&na, addr_family) < 0) {
int xerrno = errno;

destroy_pool(c->pool);
(void) close(fd);

errno = xerrno;
return NULL;
}

Expand Down

0 comments on commit 5ac5945

Please sign in to comment.