diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-04-12 21:29:39 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-04-13 08:42:45 +0200 |
commit | 3d95217745cd269e6911a0830f7e6cc515828f07 (patch) | |
tree | 7cc372d8874c2d994c444199360c040778c3e153 /src/plugins/irc/irc-protocol.c | |
parent | c80dc2a5ca93045ed7c358a8860532aab72f0c89 (diff) | |
download | weechat-3d95217745cd269e6911a0830f7e6cc515828f07.zip |
api: return allocated string in hook_info callback and function info_get
Diffstat (limited to 'src/plugins/irc/irc-protocol.c')
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index f82edc339..777141e2c 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -2169,6 +2169,7 @@ IRC_PROTOCOL_CALLBACK(pong) IRC_PROTOCOL_CALLBACK(privmsg) { char *pos_args, *pos_target, str_tags[1024], *str_color, status_msg[2]; + char *color; const char *remote_nick, *pv_tags; int is_channel, nick_is_me; struct t_irc_channel *ptr_channel; @@ -2246,8 +2247,10 @@ IRC_PROTOCOL_CALLBACK(privmsg) else { /* standard message (to "#channel") */ - str_color = irc_color_for_tags ( - irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick)); + color = irc_nick_find_color_name ((ptr_nick) ? ptr_nick->name : nick); + str_color = irc_color_for_tags (color); + if (color) + free (color); snprintf (str_tags, sizeof (str_tags), "notify_message,prefix_nick_%s", (str_color) ? str_color : "default"); @@ -2318,8 +2321,10 @@ IRC_PROTOCOL_CALLBACK(privmsg) { if (weechat_config_boolean (irc_config_look_color_pv_nick_like_channel)) { - str_color = irc_color_for_tags ( - irc_nick_find_color_name (nick)); + color = irc_nick_find_color_name (nick); + str_color = irc_color_for_tags (color); + if (color) + free (color); } else { @@ -4667,7 +4672,7 @@ IRC_PROTOCOL_CALLBACK(352) IRC_PROTOCOL_CALLBACK(353) { char *pos_channel, *pos_nick, *pos_nick_orig, *pos_host, *nickname; - char *prefixes, *str_nicks; + char *prefixes, *str_nicks, *color; int args, i, length; struct t_irc_channel *ptr_channel; @@ -4764,7 +4769,12 @@ IRC_PROTOCOL_CALLBACK(353) if (irc_server_strcasecmp (server, nickname, server->nick) == 0) strcat (str_nicks, IRC_COLOR_CHAT_NICK_SELF); else - strcat (str_nicks, irc_nick_find_color (nickname)); + { + color = irc_nick_find_color (nickname); + strcat (str_nicks, color); + if (color) + free (color); + } } else strcat (str_nicks, IRC_COLOR_RESET); @@ -4956,7 +4966,7 @@ IRC_PROTOCOL_CALLBACK(366) struct t_infolist *infolist; struct t_config_option *ptr_option; int num_nicks, num_op, num_halfop, num_voice, num_normal, length, i; - char *string, str_nicks_count[2048]; + char *string, str_nicks_count[2048], *color; const char *prefix, *prefix_color, *nickname; IRC_PROTOCOL_MIN_ARGS(5); @@ -5029,7 +5039,12 @@ IRC_PROTOCOL_CALLBACK(366) if (irc_server_strcasecmp (server, nickname, server->nick) == 0) strcat (string, IRC_COLOR_CHAT_NICK_SELF); else - strcat (string, irc_nick_find_color (nickname)); + { + color = irc_nick_find_color (nickname); + strcat (string, color); + if (color) + free (color); + } } else strcat (string, IRC_COLOR_RESET); |