From 3f31d9bd5a92013003522e6c73167aa12c77375d Mon Sep 17 00:00:00 2001 From: deepend Date: Sun, 15 Feb 2026 15:12:00 -0700 Subject: [PATCH] Fixed the plugin/script load callback to avoid using a potentially stale session pointer from the file dialog callback userdata; it now resolves a safe target session at callback time. This prevents crashes when the original session is no longer valid. Added a defensive check that reports a user-facing error ("No active session available for loading addons.") and exits early when no valid session exists, instead of calling handle_command() with invalid state. Updated the file request call to pass NULL userdata for load operations, so the callback no longer retains a stale session pointer while the chooser is open. --- src/fe-gtk/plugingui.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 439e3cd3..f41bcecb 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -175,15 +175,24 @@ fe_pluginlist_update (void) static void plugingui_load_cb (session *sess, char *file) { + session *target_sess; + if (file) { char *buf; + target_sess = is_session (sess) ? sess : current_sess; + if (!is_session (target_sess)) + { + fe_message (_("No active session available for loading addons."), FE_MSG_ERROR); + return; + } + if (strchr (file, ' ')) buf = g_strdup_printf ("LOAD \"%s\"", file); else buf = g_strdup_printf ("LOAD %s", file); - handle_command (sess, buf, FALSE); + handle_command (target_sess, buf, FALSE); g_free (buf); } } @@ -193,7 +202,7 @@ plugingui_load (void) { char *sub_dir = g_build_filename (get_xdir(), "addons", NULL); - gtkutil_file_req (NULL, _("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, + gtkutil_file_req (NULL, _("Select a Plugin or Script to load"), plugingui_load_cb, NULL, sub_dir, "*."PLUGIN_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS); g_free (sub_dir);