summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.asciidoc1
-rw-r--r--src/plugins/relay/weechat/relay-weechat-protocol.c59
2 files changed, 58 insertions, 2 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc
index 8dc6163df..534aea10d 100644
--- a/ChangeLog.asciidoc
+++ b/ChangeLog.asciidoc
@@ -62,6 +62,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* lua: fix interpreter used after unload of a script
* perl: fix context used after unload of a script
* python: fix interpreter used after unload of a script
+* relay: fix crash on /upgrade received from a client (weechat protocol)
* relay: add info "relay_client_count" with optional status name as argument
* relay: add signals "relay_client_xxx" for client status changes (closes #2)
* relay: add option relay.network.clients_purge_delay
diff --git a/src/plugins/relay/weechat/relay-weechat-protocol.c b/src/plugins/relay/weechat/relay-weechat-protocol.c
index 7820ecab0..23e780bd2 100644
--- a/src/plugins/relay/weechat/relay-weechat-protocol.c
+++ b/src/plugins/relay/weechat/relay-weechat-protocol.c
@@ -333,6 +333,43 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(nicklist)
}
/*
+ * Timer callback for input command.
+ */
+
+int
+relay_weechat_protocol_input_timer_cb (void *data,
+ int remaining_calls)
+{
+ char **timer_args;
+ int i;
+ struct t_gui_buffer *ptr_buffer;
+
+ /* make C compiler happy */
+ (void) remaining_calls;
+
+ timer_args = (char **)data;
+
+ if (!timer_args)
+ return WEECHAT_RC_ERROR;
+
+ if (timer_args[0] && timer_args[1] && timer_args[2])
+ {
+ ptr_buffer = weechat_buffer_search (timer_args[0], timer_args[1]);
+ if (ptr_buffer)
+ weechat_command (ptr_buffer, timer_args[2]);
+ }
+
+ for (i = 0; i < 3; i++)
+ {
+ if (timer_args[i])
+ free (timer_args[i]);
+ }
+ free (timer_args);
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* Callback for command "input" (from client).
*
* Message looks like:
@@ -344,7 +381,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(nicklist)
RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
{
struct t_gui_buffer *ptr_buffer;
- char *pos;
+ char *pos, **timer_args;
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(2);
@@ -353,7 +390,25 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(input)
{
pos = strchr (argv_eol[0], ' ');
if (pos)
- weechat_command (ptr_buffer, pos + 1);
+ {
+ /*
+ * use a timer to execute the command after we go back in the
+ * WeeChat main loop (some commands like /upgrade executed now can
+ * cause a crash)
+ */
+ timer_args = malloc (3 * sizeof (*timer_args));
+ if (timer_args)
+ {
+ timer_args[0] = strdup (weechat_buffer_get_string (ptr_buffer,
+ "plugin"));
+ timer_args[1] = strdup (weechat_buffer_get_string (ptr_buffer,
+ "name"));
+ timer_args[2] = strdup (pos + 1);
+ weechat_hook_timer (1, 0, 1,
+ &relay_weechat_protocol_input_timer_cb,
+ timer_args);
+ }
+ }
}
return WEECHAT_RC_OK;