[glib/mcatanzaro/#2020] Fix crash caused by g_network_monitor_base_add_network()
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/mcatanzaro/#2020] Fix crash caused by g_network_monitor_base_add_network()
- Date: Mon, 27 Jan 2020 22:25:21 +0000 (UTC)
commit 394a72bc1124ed279e51922b9d81bf24e8419020
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Jan 27 16:20:20 2020 -0600
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
gio/gnetworkmonitorbase.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
---
diff --git a/gio/gnetworkmonitorbase.c b/gio/gnetworkmonitorbase.c
index be6ec7277..d503759c1 100644
--- a/gio/gnetworkmonitorbase.c
+++ b/gio/gnetworkmonitorbase.c
@@ -496,11 +496,9 @@ void
g_network_monitor_base_add_network (GNetworkMonitorBase *monitor,
GInetAddressMask *network)
{
- if (!g_hash_table_add (monitor->priv->networks, network))
+ if (!g_hash_table_add (monitor->priv->networks, g_object_ref (network)))
return;
- g_object_ref (network); /* for the element now stored in the hash table */
-
if (g_inet_address_mask_get_length (network) == 0)
{
switch (g_inet_address_mask_get_family (network))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]