mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-23 19:24:38 +00:00
shared: relax assertion in nm_utils_parse_inaddr()/nm_utils_parse_inaddr_prefix()
The assertion fails in nmtui's ip_route_transform_from_dest_string(),
which does not initialize the address output argument to %NULL.
There are three possibilities how the API could work:
- assert/require the user to pass in arguments which pre-initialized
to NULL or unset.
- always set the output arguments, even if the function fails.
- don't bother and leave output values untouched, if function fails.
It's not clear which approach is the best. Not to bother possibliy
leaves uninitialized values, which could be error prone. Still, do
just that.
Fixes: 0b3197a3fd
This commit is contained in:
parent
fa40fc6d76
commit
9ad60ad092
|
@ -489,8 +489,6 @@ nm_utils_parse_inaddr (int addr_family,
|
|||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
||||
nm_assert (!out_addr || !*out_addr);
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin (addr_family, text, &addr_family, &addrbin))
|
||||
return FALSE;
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
|
@ -552,8 +550,6 @@ nm_utils_parse_inaddr_prefix (int addr_family,
|
|||
NMIPAddr addrbin;
|
||||
char addrstr_buf[MAX (INET_ADDRSTRLEN, INET6_ADDRSTRLEN)];
|
||||
|
||||
nm_assert (!out_addr || !*out_addr);
|
||||
|
||||
if (!nm_utils_parse_inaddr_prefix_bin (addr_family, text, &addr_family, &addrbin, out_prefix))
|
||||
return FALSE;
|
||||
NM_SET_OUT (out_addr, g_strdup (inet_ntop (addr_family, &addrbin, addrstr_buf, sizeof (addrstr_buf))));
|
||||
|
|
Loading…
Reference in a new issue