mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 05:13:06 +02:00
gwin32networkmonitor: Fix returning address of local variable
Something has changed recently which causes this error to now be emitted when building on Windows msys2-mingw32: ``` ../gio/gwin32networkmonitor.c: In function 'win_network_monitor_get_ip_info': ../gio/gwin32networkmonitor.c:92:15: error: storing the address of local variable 'prefix' in '*dest' [-Werror=dangling-pointer=] 92 | *dest = (guint8 *) &prefix.Prefix.Ipv4.sin_addr; | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` If `IP_ADDRESS_PREFIX` is defined as a scalar rather than a pointer, that could explain the problem. Change the function to always operate on a pointer to avoid any potential such issues. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
de2ff26454
commit
e59e8ebf31
@ -78,24 +78,24 @@ g_win32_network_monitor_init (GWin32NetworkMonitor *win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
win_network_monitor_get_ip_info (IP_ADDRESS_PREFIX prefix,
|
win_network_monitor_get_ip_info (const IP_ADDRESS_PREFIX *prefix,
|
||||||
GSocketFamily *family,
|
GSocketFamily *family,
|
||||||
const guint8 **dest,
|
const guint8 **dest,
|
||||||
gsize *len)
|
gsize *len)
|
||||||
{
|
{
|
||||||
switch (prefix.Prefix.si_family)
|
switch (prefix->Prefix.si_family)
|
||||||
{
|
{
|
||||||
case AF_UNSPEC:
|
case AF_UNSPEC:
|
||||||
/* Fall-through: AF_UNSPEC deliveres both IPV4 and IPV6 infos, let`s stick with IPV4 here */
|
/* Fall-through: AF_UNSPEC deliveres both IPV4 and IPV6 infos, let`s stick with IPV4 here */
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
*family = G_SOCKET_FAMILY_IPV4;
|
*family = G_SOCKET_FAMILY_IPV4;
|
||||||
*dest = (guint8 *) &prefix.Prefix.Ipv4.sin_addr;
|
*dest = (guint8 *) &(prefix->Prefix.Ipv4.sin_addr);
|
||||||
*len = prefix.PrefixLength;
|
*len = prefix->PrefixLength;
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
*family = G_SOCKET_FAMILY_IPV6;
|
*family = G_SOCKET_FAMILY_IPV6;
|
||||||
*dest = (guint8 *) &prefix.Prefix.Ipv6.sin6_addr;
|
*dest = (guint8 *) &(prefix->Prefix.Ipv6.sin6_addr);
|
||||||
*len = prefix.PrefixLength;
|
*len = prefix->PrefixLength;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -152,7 +152,7 @@ win_network_monitor_process_table (GWin32NetworkMonitor *win,
|
|||||||
|
|
||||||
route = routes->Table + i;
|
route = routes->Table + i;
|
||||||
|
|
||||||
if (!win_network_monitor_get_ip_info (route->DestinationPrefix, &family, &dest, &len))
|
if (!win_network_monitor_get_ip_info (&route->DestinationPrefix, &family, &dest, &len))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
network = get_network_mask (family, dest, len);
|
network = get_network_mask (family, dest, len);
|
||||||
@ -218,13 +218,13 @@ win_network_monitor_invoke_route_changed (gpointer user_data)
|
|||||||
switch (route_data->type)
|
switch (route_data->type)
|
||||||
{
|
{
|
||||||
case MibDeleteInstance:
|
case MibDeleteInstance:
|
||||||
if (!win_network_monitor_get_ip_info (route_data->route->DestinationPrefix, &family, &dest, &len))
|
if (!win_network_monitor_get_ip_info (&route_data->route->DestinationPrefix, &family, &dest, &len))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
remove_network (route_data->win, family, dest, len);
|
remove_network (route_data->win, family, dest, len);
|
||||||
break;
|
break;
|
||||||
case MibAddInstance:
|
case MibAddInstance:
|
||||||
if (!win_network_monitor_get_ip_info (route_data->route->DestinationPrefix, &family, &dest, &len))
|
if (!win_network_monitor_get_ip_info (&route_data->route->DestinationPrefix, &family, &dest, &len))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
add_network (route_data->win, family, dest, len);
|
add_network (route_data->win, family, dest, len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user