mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
wireaddr: handle case where non-IPv6 and non-IPv4 address is returned.
Thanks clang! Here's the error:
ommon/wireaddr.c:359:14: error: variable 'addr' is used uninitialized whenever
'if' condition is false [-Werror,-Wsometimes-uninitialized]
} else if (addrinfo->ai_family == AF_INET6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/wireaddr.c:364:25: note: uninitialized use occurs here
tal_arr_expand(addrs, addr);
^~~~
./common/utils.h:27:16: note: expanded from macro 'tal_arr_expand'
(*(p))[n] = (s); \
^
common/wireaddr.c:359:10: note: remove the 'if' if its condition is always true
} else if (addrinfo->ai_family == AF_INET6) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/wireaddr.c:354:3: note: variable 'addr' is declared here
struct wireaddr addr;
^
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -360,7 +360,9 @@ bool wireaddr_from_hostname(struct wireaddr **addrs, const char *hostname,
|
|||||||
sa6 = (struct sockaddr_in6 *) addrinfo->ai_addr;
|
sa6 = (struct sockaddr_in6 *) addrinfo->ai_addr;
|
||||||
wireaddr_from_ipv6(&addr, &sa6->sin6_addr, port);
|
wireaddr_from_ipv6(&addr, &sa6->sin6_addr, port);
|
||||||
res = true;
|
res = true;
|
||||||
}
|
} else
|
||||||
|
/* Ignore any other address types. */
|
||||||
|
continue;
|
||||||
tal_arr_expand(addrs, addr);
|
tal_arr_expand(addrs, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user