summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-11 09:14:34 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-02-11 09:14:34 -0500
commit95d48ac2e81df1f382669e4795cc3a9de151a252 (patch)
tree110cba0180a29ae2ca94e441d8aeb08c043b9c8a
parent0cc43e10a51bbd6be2c97a257af0d57fe2d37e0d (diff)
downloadgtk+-fix-network-places.tar.gz
placesview: Avoid use-after-freefix-network-places
The places view has questionable code for handling 'destroy', which seems to trigger use-after-free in some cases. Clean this up a bit by acknowledging the cancellation fully, rather than relying on the destroyed flag.
-rw-r--r--gtk/gtkplacesview.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index aec0ddea60..4d26337155 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -986,9 +986,14 @@ network_enumeration_next_files_finished (GObject *source_object,
if (error)
{
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Failed to fetch network locations: %s", error->message);
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ {
+ g_clear_error (&error);
+ g_object_unref (view);
+ return;
+ }
+ g_warning ("Failed to fetch network locations: %s", error->message);
g_clear_error (&error);
}
else
@@ -999,16 +1004,11 @@ network_enumeration_next_files_finished (GObject *source_object,
g_list_free_full (detected_networks, g_object_unref);
}
- g_object_unref (view);
+ update_network_state (view);
+ monitor_network (view);
+ update_loading (view);
- /* avoid to update widgets if we are already destroyed
- (and got cancelled s a result of that) */
- if (!view->destroyed)
- {
- update_network_state (view);
- monitor_network (view);
- update_loading (view);
- }
+ g_object_unref (view);
}
static void