Commit 9179e9fa authored by Linus Nordberg's avatar Linus Nordberg
Browse files

Don't use 'out' if malloc fails.

coverity: 1449518
parent 3a5d0a04
...@@ -68,17 +68,17 @@ struct sockaddr *addr_copy(struct sockaddr *in) { ...@@ -68,17 +68,17 @@ struct sockaddr *addr_copy(struct sockaddr *in) {
switch (in->sa_family) { switch (in->sa_family) {
case AF_INET: case AF_INET:
out = malloc(sizeof(struct sockaddr_in)); out = malloc(sizeof(struct sockaddr_in));
if (out) { if (out == NULL)
memset(out, 0, sizeof(struct sockaddr_in)); return NULL;
((struct sockaddr_in *)out)->sin_addr = ((struct sockaddr_in *)in)->sin_addr; memset(out, 0, sizeof(struct sockaddr_in));
} ((struct sockaddr_in *)out)->sin_addr = ((struct sockaddr_in *)in)->sin_addr;
break; break;
case AF_INET6: case AF_INET6:
out = malloc(sizeof(struct sockaddr_in6)); out = malloc(sizeof(struct sockaddr_in6));
if (out) { if (out == NULL)
memset(out, 0, sizeof(struct sockaddr_in6)); return NULL;
((struct sockaddr_in6 *)out)->sin6_addr = ((struct sockaddr_in6 *)in)->sin6_addr; memset(out, 0, sizeof(struct sockaddr_in6));
} ((struct sockaddr_in6 *)out)->sin6_addr = ((struct sockaddr_in6 *)in)->sin6_addr;
break; break;
} }
out->sa_family = in->sa_family; out->sa_family = in->sa_family;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment