From 95538794e3642175484595f5c99fd8a09d182ac7 Mon Sep 17 00:00:00 2001 From: deepend Date: Sun, 15 Feb 2026 15:02:26 -0700 Subject: [PATCH] Fixed the GTK file chooser handling to avoid dereferencing/processing invalid filenames by adding an early guard in gtkutil_check_file() for NULL/empty selections, which prevents the load flow from continuing with bad input. Fixed the single-file open path in gtkutil_file_req_done() to fetch the filename once and only call gtkutil_check_file() when a non-NULL filename is returned, preventing the crash path when GTK returns no file on accept/load. --- src/fe-gtk/gtkutil.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index f4c2258a..39660ed2 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -362,6 +362,12 @@ gtkutil_check_file (char *filename, struct file_req *freq) { int axs = FALSE; + if (filename == NULL || filename[0] == '\0') + { + fe_message (_("No file selected."), FE_MSG_ERROR); + return; + } + GFile *file = g_file_new_for_path (filename); if (freq->flags & FRF_WRITE) @@ -453,8 +459,11 @@ gtkutil_file_req_done (GtkWidget * wid, struct file_req *freq) else { gchar *filename = gtk_file_chooser_get_filename (fs); - gtkutil_check_file (gtk_file_chooser_get_filename (fs), freq); - g_free (filename); + if (filename != NULL) + { + gtkutil_check_file (filename, freq); + g_free (filename); + } } }