Skip to content

Commit

Permalink
Fix double free of host and serv variables (droe#320)
Browse files Browse the repository at this point in the history
Thanks to @disaykin
  • Loading branch information
disaykin authored May 15, 2023
1 parent d3b7a5b commit 31727da
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,15 @@ sys_sockaddr_str(struct sockaddr *addr, socklen_t addrlen,
log_err_printf("Cannot get nameinfo for socket address: %s\n",
gai_strerror(rv));
free(*serv);
*serv = NULL;
return -1;
}
hostsz = strlen(tmphost) + 1; /* including terminator */
*host = malloc(hostsz);
if (!*host) {
log_err_printf("Cannot allocate memory\n");
free(*serv);
*serv = NULL;
return -1;
}
memcpy(*host, tmphost, hostsz);
Expand Down

0 comments on commit 31727da

Please sign in to comment.