diff options
author | Ondrej Holy <oholy@redhat.com> | 2020-02-26 09:13:25 +0100 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2020-02-28 08:15:48 +0000 |
commit | 6b16de613dc87b9f84d87a46ac5987b6d7087a5c (patch) | |
tree | 1cf38b94677e555e307fa8d3f8e637b0aeea0391 /src | |
parent | 38c4b8592e0b531135df7bb51461f39ed0a81d7c (diff) | |
download | nautilus-6b16de613dc87b9f84d87a46ac5987b6d7087a5c.tar.gz |
window-slot: Prevent crashes caused by invalid pointers
Nautilus randomly crashes when g_object_bind_property is used to bind
extensions-background-menu and templates-menu properties of
NautilusFilesView and NautilusWindowSlot. Although, we don't have any
reproducer, it seems that this is because NautilusWindowSlot uses
g_object_ref when storing the property, but not g_object_unref, and
NautilusFilesView does the opposite. It seems that NautilusFilesView
can hold invalid references in certain cases because of that. The
both objects should hold its own references to prevent this. Let's
replace the custom codes by g_set_object to achive this behavior.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/issues/813
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-files-view.c | 6 | ||||
-rw-r--r-- | src/nautilus-window-slot.c | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index 427ac08c5..5573701cc 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -776,8 +776,7 @@ real_set_extensions_background_menu (NautilusView *view, priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view)); - g_clear_object (&priv->extensions_background_menu); - priv->extensions_background_menu = menu; + g_set_object (&priv->extensions_background_menu, menu); } static void @@ -790,8 +789,7 @@ real_set_templates_menu (NautilusView *view, priv = nautilus_files_view_get_instance_private (NAUTILUS_FILES_VIEW (view)); - g_clear_object (&priv->templates_menu); - priv->templates_menu = menu; + g_set_object (&priv->templates_menu, menu); } static gboolean diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index ee15f4c68..7fe24f09c 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -769,7 +769,7 @@ real_set_extensions_background_menu (NautilusWindowSlot *self, NautilusWindowSlotPrivate *priv; priv = nautilus_window_slot_get_instance_private (self); - priv->extensions_background_menu = menu != NULL ? g_object_ref (menu) : NULL; + g_set_object (&priv->extensions_background_menu, menu); } static void @@ -779,7 +779,7 @@ real_set_templates_menu (NautilusWindowSlot *self, NautilusWindowSlotPrivate *priv; priv = nautilus_window_slot_get_instance_private (self); - priv->templates_menu = menu != NULL ? g_object_ref (menu) : NULL; + g_set_object (&priv->templates_menu, menu); } static void |