Commit bec695f3 by Dwight Engen Committed by Serge Hallyn

coverity: fix leak when ipv6 gw is auto

parent 8950ee8e
......@@ -782,12 +782,6 @@ static int config_network_ipv6_gateway(const char *key, const char *value,
if (!netdev)
return -1;
gw = malloc(sizeof(*gw));
if (!gw) {
SYSERROR("failed to allocate ipv6 gateway address");
return -1;
}
if (!value) {
ERROR("no ipv6 gateway address specified");
return -1;
......@@ -797,6 +791,12 @@ static int config_network_ipv6_gateway(const char *key, const char *value,
netdev->ipv6_gateway = NULL;
netdev->ipv6_gateway_auto = true;
} else {
gw = malloc(sizeof(*gw));
if (!gw) {
SYSERROR("failed to allocate ipv6 gateway address");
return -1;
}
if (!inet_pton(AF_INET6, value, gw)) {
SYSERROR("invalid ipv6 gateway address: %s", value);
free(gw);
......
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