mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-20 04:30:18 +00:00
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.
This commit is contained in:
@@ -175,15 +175,24 @@ fe_pluginlist_update (void)
|
|||||||
static void
|
static void
|
||||||
plugingui_load_cb (session *sess, char *file)
|
plugingui_load_cb (session *sess, char *file)
|
||||||
{
|
{
|
||||||
|
session *target_sess;
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
char *buf;
|
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, ' '))
|
if (strchr (file, ' '))
|
||||||
buf = g_strdup_printf ("LOAD \"%s\"", file);
|
buf = g_strdup_printf ("LOAD \"%s\"", file);
|
||||||
else
|
else
|
||||||
buf = g_strdup_printf ("LOAD %s", file);
|
buf = g_strdup_printf ("LOAD %s", file);
|
||||||
handle_command (sess, buf, FALSE);
|
handle_command (target_sess, buf, FALSE);
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +202,7 @@ plugingui_load (void)
|
|||||||
{
|
{
|
||||||
char *sub_dir = g_build_filename (get_xdir(), "addons", NULL);
|
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);
|
sub_dir, "*."PLUGIN_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
|
||||||
|
|
||||||
g_free (sub_dir);
|
g_free (sub_dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user