syslogd: Fix invalid free(), found by Valgrind

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-13 18:35:27 +01:00
parent b0ff1aa5c7
commit 6350bf2474

View File

@ -77,15 +77,13 @@ int socket_register(int sd, struct addrinfo *ai, void (*cb)(int, void *), void *
goto err;
if (ai) {
struct sockaddr_un *sun;
memcpy(&entry->ai, ai, sizeof(*ai));
sun = calloc(1, sizeof(struct sockaddr_un));
if (!sun)
entry->ai.ai_addr = calloc(1, ai->ai_addrlen);
if (!entry->ai.ai_addr)
goto eaddr;
entry->ai.ai_addr = (struct sockaddr *)sun;
entry->ai = *ai;
*entry->ai.ai_addr = *ai->ai_addr;
memcpy(entry->ai.ai_addr, ai->ai_addr, ai->ai_addrlen);
}
entry->sd = sd;