1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

irc: fix crash when command "/buffer close" is used in a server command to close server buffer during connection (bug #33763)

This commit is contained in:
Sebastien Helleu
2011-07-13 18:28:29 +02:00
parent 1f027dbeb1
commit 47822ce80e
3 changed files with 141 additions and 135 deletions
+3 -1
View File
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.6-dev, 2011-07-12
v0.3.6-dev, 2011-07-13
Version 0.3.6 (under dev!)
@@ -29,6 +29,8 @@ Version 0.3.6 (under dev!)
hdata_get_string
* api: fix bug with function config_set_desc_plugin (use immediately
description for option when function is called)
* irc: fix crash when command "/buffer close" is used in a server command to
close server buffer during connection (bug #33763)
* irc: fix crash when /join command is executed on a non-irc buffer (bug #33742)
* irc: fix bug with comma in irc color code: do not strip comma if it is not
followed by a digit (bug #33662)
+1 -1
View File
@@ -198,7 +198,7 @@ irc_ignore_check (struct t_irc_server *server, const char *channel,
* if nick is the same as server, then we will not ignore
* (it is possible when connected to an irc proxy)
*/
if (nick && (strcmp (server->nick, nick) == 0))
if (nick && server->nick && (strcmp (server->nick, nick) == 0))
return 0;
for (ptr_ignore = irc_ignore_list; ptr_ignore;
+137 -133
View File
@@ -1914,164 +1914,168 @@ irc_server_msgq_flush ()
{
if (irc_recv_msgq->data)
{
ptr_data = irc_recv_msgq->data;
while (ptr_data[0] == ' ')
/* read message only if connection was not lost */
if (irc_recv_msgq->server->sock != -1)
{
ptr_data++;
}
if (ptr_data[0])
{
irc_raw_print (irc_recv_msgq->server, IRC_RAW_FLAG_RECV,
ptr_data);
irc_message_parse (ptr_data, NULL, NULL, &command, NULL, NULL);
snprintf (str_modifier, sizeof (str_modifier),
"irc_in_%s",
(command) ? command : "unknown");
new_msg = weechat_hook_modifier_exec (str_modifier,
irc_recv_msgq->server->name,
ptr_data);
if (command)
free (command);
/* no changes in new message */
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
ptr_data = irc_recv_msgq->data;
while (ptr_data[0] == ' ')
{
free (new_msg);
new_msg = NULL;
ptr_data++;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
if (ptr_data[0])
{
/* use new message (returned by plugin) */
ptr_msg = (new_msg) ? new_msg : ptr_data;
irc_raw_print (irc_recv_msgq->server, IRC_RAW_FLAG_RECV,
ptr_data);
while (ptr_msg && ptr_msg[0])
irc_message_parse (ptr_data, NULL, NULL, &command, NULL, NULL);
snprintf (str_modifier, sizeof (str_modifier),
"irc_in_%s",
(command) ? command : "unknown");
new_msg = weechat_hook_modifier_exec (str_modifier,
irc_recv_msgq->server->name,
ptr_data);
if (command)
free (command);
/* no changes in new message */
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
{
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
free (new_msg);
new_msg = NULL;
}
/* message not dropped? */
if (!new_msg || new_msg[0])
{
/* use new message (returned by plugin) */
ptr_msg = (new_msg) ? new_msg : ptr_data;
if (new_msg)
while (ptr_msg && ptr_msg[0])
{
irc_raw_print (irc_recv_msgq->server,
IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED,
ptr_msg);
}
irc_message_parse (ptr_msg, &nick, &host, &command,
&channel, &arguments);
/* convert charset for message */
if (channel && irc_channel_is_channel (channel))
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s.%s",
weechat_plugin->name,
irc_recv_msgq->server->name,
channel);
}
else
{
if (nick && (!host || (strcmp (nick, host) != 0)))
pos = strchr (ptr_msg, '\n');
if (pos)
pos[0] = '\0';
if (new_msg)
{
irc_raw_print (irc_recv_msgq->server,
IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED,
ptr_msg);
}
irc_message_parse (ptr_msg, &nick, &host, &command,
&channel, &arguments);
/* convert charset for message */
if (channel && irc_channel_is_channel (channel))
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s.%s",
weechat_plugin->name,
irc_recv_msgq->server->name,
nick);
channel);
}
else
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s",
weechat_plugin->name,
irc_recv_msgq->server->name);
if (nick && (!host || (strcmp (nick, host) != 0)))
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s.%s",
weechat_plugin->name,
irc_recv_msgq->server->name,
nick);
}
else
{
snprintf (modifier_data, sizeof (modifier_data),
"%s.%s",
weechat_plugin->name,
irc_recv_msgq->server->name);
}
}
}
msg_decoded = weechat_hook_modifier_exec ("charset_decode",
modifier_data,
ptr_msg);
/* replace WeeChat internal color codes by "?" */
msg_decoded_without_color =
weechat_string_remove_color ((msg_decoded) ? msg_decoded : ptr_msg,
"?");
/* call modifier after charset */
ptr_msg2 = (msg_decoded_without_color) ?
msg_decoded_without_color : ((msg_decoded) ? msg_decoded : ptr_msg);
snprintf (str_modifier, sizeof (str_modifier),
"irc_in2_%s",
(command) ? command : "unknown");
new_msg2 = weechat_hook_modifier_exec (str_modifier,
irc_recv_msgq->server->name,
ptr_msg2);
if (new_msg2 && (strcmp (ptr_msg2, new_msg2) == 0))
{
free (new_msg2);
new_msg2 = NULL;
}
/* message not dropped? */
if (!new_msg2 || new_msg2[0])
{
/* use new message (returned by plugin) */
if (new_msg2)
ptr_msg2 = new_msg2;
msg_decoded = weechat_hook_modifier_exec ("charset_decode",
modifier_data,
ptr_msg);
/* parse and execute command */
if (irc_redirect_message (irc_recv_msgq->server,
ptr_msg2, command,
arguments))
/* replace WeeChat internal color codes by "?" */
msg_decoded_without_color =
weechat_string_remove_color ((msg_decoded) ? msg_decoded : ptr_msg,
"?");
/* call modifier after charset */
ptr_msg2 = (msg_decoded_without_color) ?
msg_decoded_without_color : ((msg_decoded) ? msg_decoded : ptr_msg);
snprintf (str_modifier, sizeof (str_modifier),
"irc_in2_%s",
(command) ? command : "unknown");
new_msg2 = weechat_hook_modifier_exec (str_modifier,
irc_recv_msgq->server->name,
ptr_msg2);
if (new_msg2 && (strcmp (ptr_msg2, new_msg2) == 0))
{
/* message redirected, we'll not display it! */
free (new_msg2);
new_msg2 = NULL;
}
/* message not dropped? */
if (!new_msg2 || new_msg2[0])
{
/* use new message (returned by plugin) */
if (new_msg2)
ptr_msg2 = new_msg2;
/* parse and execute command */
if (irc_redirect_message (irc_recv_msgq->server,
ptr_msg2, command,
arguments))
{
/* message redirected, we'll not display it! */
}
else
{
/* message not redirected, display it */
irc_protocol_recv_command (irc_recv_msgq->server,
ptr_msg2, command,
channel);
}
}
if (new_msg2)
free (new_msg2);
if (nick)
free (nick);
if (host)
free (host);
if (command)
free (command);
if (channel)
free (channel);
if (arguments)
free (arguments);
if (msg_decoded)
free (msg_decoded);
if (msg_decoded_without_color)
free (msg_decoded_without_color);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
{
/* message not redirected, display it */
irc_protocol_recv_command (irc_recv_msgq->server,
ptr_msg2, command,
channel);
}
ptr_msg = NULL;
}
if (new_msg2)
free (new_msg2);
if (nick)
free (nick);
if (host)
free (host);
if (command)
free (command);
if (channel)
free (channel);
if (arguments)
free (arguments);
if (msg_decoded)
free (msg_decoded);
if (msg_decoded_without_color)
free (msg_decoded_without_color);
if (pos)
{
pos[0] = '\n';
ptr_msg = pos + 1;
}
else
ptr_msg = NULL;
}
else
{
irc_raw_print (irc_recv_msgq->server,
IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED,
_("(message dropped)"));
}
if (new_msg)
free (new_msg);
}
else
{
irc_raw_print (irc_recv_msgq->server,
IRC_RAW_FLAG_RECV | IRC_RAW_FLAG_MODIFIED,
_("(message dropped)"));
}
if (new_msg)
free (new_msg);
}
free (irc_recv_msgq->data);
}