mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 22:52:09 +01:00
Fix crash caused by g_network_monitor_base_add_network()
This avoids a crash when starting Evolution, and fixes the network-monitor and network-monitor-race test cases on my developer workstation. (I assume the CI is not crashing due to lack of network access there.) Problem is that if a network already exists in the networks table, g_hash_table_add() "destroys" (unrefs) it before adding the new one (which we failed to ref before adding). This means we just accidentally lost a ref. In practice, the network gets unexpectedly destroyed here before returning. Fixes #2020
This commit is contained in:
parent
ab32d5c920
commit
394a72bc11
@ -496,11 +496,9 @@ void
|
|||||||
g_network_monitor_base_add_network (GNetworkMonitorBase *monitor,
|
g_network_monitor_base_add_network (GNetworkMonitorBase *monitor,
|
||||||
GInetAddressMask *network)
|
GInetAddressMask *network)
|
||||||
{
|
{
|
||||||
if (!g_hash_table_add (monitor->priv->networks, network))
|
if (!g_hash_table_add (monitor->priv->networks, g_object_ref (network)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_object_ref (network); /* for the element now stored in the hash table */
|
|
||||||
|
|
||||||
if (g_inet_address_mask_get_length (network) == 0)
|
if (g_inet_address_mask_get_length (network) == 0)
|
||||||
{
|
{
|
||||||
switch (g_inet_address_mask_get_family (network))
|
switch (g_inet_address_mask_get_family (network))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user