platform: ensure NM_SOCK_ADDR_UNION_INIT_UNSPEC() fully initializes union
In C, initialization of a union does not define that excess memory is initialized. Ensure that, by initializing the largest member of the NMSockAddrUnion union.
This commit is contained in:
@@ -34,10 +34,14 @@ typedef union {
|
|||||||
struct sockaddr_in6 in6;
|
struct sockaddr_in6 in6;
|
||||||
} NMSockAddrUnion;
|
} NMSockAddrUnion;
|
||||||
|
|
||||||
|
G_STATIC_ASSERT(sizeof(NMSockAddrUnion) == sizeof(((NMSockAddrUnion *) NULL)->in6));
|
||||||
|
|
||||||
|
/* we initialize the largest union member, to ensure that all fields are initialized. */
|
||||||
|
|
||||||
#define NM_SOCK_ADDR_UNION_INIT_UNSPEC \
|
#define NM_SOCK_ADDR_UNION_INIT_UNSPEC \
|
||||||
{ \
|
{ \
|
||||||
.sa = { \
|
.in6 = { \
|
||||||
.sa_family = AF_UNSPEC, \
|
.sin6_family = AF_UNSPEC, \
|
||||||
}, \
|
}, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user