summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-02-27 15:49:05 +0000
committerAntónio Fernandes <antoniof@gnome.org>2021-02-27 15:53:44 +0000
commitb4c76d44593a820f3a4ef18820e93edc992d9414 (patch)
treef506135184794648a018d5fd4da34623ecfe09ac
parent0182308c1c85b0c9a0045ac6f74985649731e9d6 (diff)
downloadnautilus-1759-crash-closing-last-tab.tar.gz
window: Handle NULL active_slot pointer1759-crash-closing-last-tab
This pointer may be NULL. Usually this may happen only during window initialization and destruction. However, for robustness, make sure every use either handles a NULL pointer or asserts it's non-NULL.
-rw-r--r--src/nautilus-window.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e4294f6dd..53a4fa527 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1434,7 +1434,7 @@ nautilus_window_slot_close (NautilusWindow *window,
NautilusNavigationState *data;
DEBUG ("Requesting to remove slot %p from window %p", slot, window);
- if (window == NULL)
+ if (window == NULL || slot == NULL)
{
return;
}
@@ -1465,7 +1465,7 @@ nautilus_window_sync_bookmarks (NautilusWindow *window)
GFile *location;
slot = window->active_slot;
- location = nautilus_window_slot_get_location (slot);
+ location = slot != NULL ? nautilus_window_slot_get_location (slot) : NULL;
if (location != NULL)
{
@@ -1487,6 +1487,9 @@ nautilus_window_sync_location_widgets (NautilusWindow *window)
gboolean enabled;
slot = window->active_slot;
+ /* This function is called by the active slot. */
+ g_assert (slot != NULL);
+
location = nautilus_window_slot_get_location (slot);
/* Change the location bar and path bar to match the current location. */
@@ -1766,6 +1769,11 @@ nautilus_window_show_operation_notification (NautilusWindow *window,
NautilusFile *folder;
GFile *current_location;
+ if (window->active_slot == NULL)
+ {
+ return;
+ }
+
current_location = nautilus_window_slot_get_location (window->active_slot);
if (gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
{
@@ -2520,7 +2528,8 @@ nautilus_window_key_press_event (GtkWidget *widget,
return GDK_EVENT_STOP;
}
- if (nautilus_window_slot_handle_event (window->active_slot, (GdkEvent *) event))
+ if (window->active_slot != NULL &&
+ nautilus_window_slot_handle_event (window->active_slot, (GdkEvent *) event))
{
return GDK_EVENT_STOP;
}