diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 11:38:39 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 11:38:39 +0100 |
commit | 614b4dfc25e533cb73ca0d4bb5ef699a329e5076 (patch) | |
tree | 72a80cd6581e3911b465b44562cb60ddae3fec06 /src/plugins | |
parent | 7eabbc6bb7fad7ebf71117243389058fd9eeb6bf (diff) | |
download | weechat-614b4dfc25e533cb73ca0d4bb5ef699a329e5076.zip |
Fix zero byte malloc when joining a channel without nick
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 4c51d0265..c07dd82f8 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3630,45 +3630,48 @@ IRC_PROTOCOL_CALLBACK(366) strlen (weechat_infolist_string (infolist, "name")) + 1; } } - string = malloc (length); - if (string) + if (length > 0) { - string[0] = '\0'; - i = 0; - while (weechat_infolist_next (infolist)) + string = malloc (length); + if (string) { - if (strcmp (weechat_infolist_string (infolist, "type"), - "nick") == 0) + string[0] = '\0'; + i = 0; + while (weechat_infolist_next (infolist)) { - if (i > 0) - strcat (string, " "); - prefix = weechat_infolist_string (infolist, "prefix"); - if (prefix[0] && (prefix[0] != ' ')) + if (strcmp (weechat_infolist_string (infolist, "type"), + "nick") == 0) { - weechat_config_search_with_string (weechat_infolist_string (infolist, - "prefix_color"), - NULL, NULL, &ptr_option, - NULL); - if (ptr_option) - strcat (string, weechat_color (weechat_config_string (ptr_option))); - strcat (string, prefix); + if (i > 0) + strcat (string, " "); + prefix = weechat_infolist_string (infolist, "prefix"); + if (prefix[0] && (prefix[0] != ' ')) + { + weechat_config_search_with_string (weechat_infolist_string (infolist, + "prefix_color"), + NULL, NULL, &ptr_option, + NULL); + if (ptr_option) + strcat (string, weechat_color (weechat_config_string (ptr_option))); + strcat (string, prefix); + } + strcat (string, IRC_COLOR_CHAT); + strcat (string, weechat_infolist_string (infolist, "name")); + i++; } - strcat (string, IRC_COLOR_CHAT); - strcat (string, weechat_infolist_string (infolist, "name")); - i++; } + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags (command, "irc_numeric", NULL), + _("%sNicks %s%s%s: %s[%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + string, + IRC_COLOR_CHAT_DELIMITERS); + free (string); } - weechat_printf_tags (ptr_channel->buffer, - irc_protocol_tags (command, "irc_numeric", NULL), - _("%sNicks %s%s%s: %s[%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_DELIMITERS, - string, - IRC_COLOR_CHAT_DELIMITERS); - free (string); } weechat_infolist_free (infolist); } |