[nautilus/wip/corey/search-directory-file] search-directory-file: Check for NULL before calling callback




commit b9fa2f25d3c573e4b9acbda63b059d0aea8edf54
Author: Corey Berla <corey berla me>
Date:   Fri Sep 30 10:11:22 2022 -0700

    search-directory-file: Check for NULL before calling callback
    
    Prevent segfault when calling call_when_ready with a NULL callback
    
    This is the case with sidebar row, dc2711bd74056ed1711c0bce8dfcd9d0056bc3ad
    which attempts to get the mount information from a file.  vfs-file
    chains up to nautilus-directory and handles the NULL callback fine,
    but if somehow, the search-directory was added to the bookmarks
    (which isn't possible in current versions of Nautilus, but maybe
    was in past version), Nautilus crashes.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2513

 src/nautilus-search-directory-file.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-search-directory-file.c b/src/nautilus-search-directory-file.c
index 1a87a59a8..d118bab61 100644
--- a/src/nautilus-search-directory-file.c
+++ b/src/nautilus-search-directory-file.c
@@ -74,8 +74,11 @@ search_directory_file_call_when_ready (NautilusFile           *file,
     /* Update display name, in case this didn't happen yet */
     nautilus_search_directory_file_update_display_name (NAUTILUS_SEARCH_DIRECTORY_FILE (file));
 
-    /* All data for directory-as-file is always uptodate */
-    (*callback)(file, callback_data);
+    if (callback != NULL)
+    {
+        /* All data for directory-as-file is always up to date */
+        (*callback)(file, callback_data);
+    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]