In gateway_and_prefix_addresses_alloc prefix_len isn't set in the error case, but used unconditionally. Avoid this by initializing upon declaration.
(Identified by GCC 12.)
Signed-off-by: Gerald Pfeifer gerald@pfeifer.com --- dlls/iphlpapi/iphlpapi_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c index c94f869c9f9..720f8147476 100644 --- a/dlls/iphlpapi/iphlpapi_main.c +++ b/dlls/iphlpapi/iphlpapi_main.c @@ -992,7 +992,8 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG struct nsi_ipv6_forward_key *key6; IP_ADAPTER_GATEWAY_ADDRESS *gw, **gw_next; IP_ADAPTER_PREFIX *prefix, **prefix_next; - DWORD err, count, i, prefix_len, key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6); + DWORD err, count, i, prefix_len = 0; + DWORD key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6); DWORD sockaddr_size = (family == AF_INET) ? sizeof(SOCKADDR_IN) : sizeof(SOCKADDR_IN6); SOCKADDR_INET sockaddr; NET_LUID *luid;
On Thu, Jan 27, 2022 at 11:18:53PM +0100, Gerald Pfeifer wrote:
In gateway_and_prefix_addresses_alloc prefix_len isn't set in the error case, but used unconditionally. Avoid this by initializing upon declaration.
(Identified by GCC 12.)
It's actually not used unconditionally, since it's only used if sockaddr.si_family is non-zero, in which case it will have been initialised.
It makes more sense to zero-init where sockaddr in also initialised since we're in a loop.
I've sent in v2.
Huw.
On Fri, 28 Jan 2022, Huw Davies wrote:
It's actually not used unconditionally, since it's only used if sockaddr.si_family is non-zero, in which case it will have been initialised.
It makes more sense to zero-init where sockaddr in also initialised since we're in a loop.
I've sent in v2.
Very cool. Thank you, Huw!
Gerald