spell: fix crash with IRC color codes in command line (closes #1589)

This commit is contained in:
Sébastien Helleu 2020-11-20 21:50:05 +01:00
parent a2266e4e3f
commit ee24fac586
2 changed files with 11 additions and 9 deletions

View File

@ -26,6 +26,7 @@ New features::
Bug fixes::
* core: display an error when the buffer is not found with command /command -buffer
* spell: fix crash with IRC color codes in command line (issue #1589)
* spell: fix refresh of bar item "spell_suggest" when the input becomes empty (issue #1586)
[[v3.0]]

View File

@ -649,7 +649,7 @@ spell_skip_color_codes (char **string, char **result)
{
int color_code_size;
while (*string[0])
while ((*string)[0])
{
color_code_size = weechat_string_color_code_size (*string);
if (color_code_size > 0)
@ -658,9 +658,9 @@ spell_skip_color_codes (char **string, char **result)
weechat_string_dyn_concat (result, *string, color_code_size);
(*string) += color_code_size;
}
else if (*string[0] == '\x02' || *string[0] == '\x0F'
|| *string[0] == '\x11' || *string[0] == '\x16'
|| *string[0] == '\x1D' || *string[0] == '\x1F')
else if ((*string)[0] == '\x02' || (*string)[0] == '\x0F'
|| (*string)[0] == '\x11' || (*string)[0] == '\x16'
|| (*string)[0] == '\x1D' || (*string)[0] == '\x1F')
{
/*
* IRC attribute:
@ -674,28 +674,29 @@ spell_skip_color_codes (char **string, char **result)
weechat_string_dyn_concat (result, *string, 1);
(*string)++;
}
else if (*string[0] == '\x03')
else if ((*string)[0] == '\x03')
{
/* IRC color code */
weechat_string_dyn_concat (result, *string, 1);
(*string)++;
if (isdigit ((unsigned char)*string[0]))
if (isdigit ((unsigned char)((*string)[0])))
{
/* foreground */
weechat_string_dyn_concat (result, *string, 1);
(*string)++;
if (isdigit ((unsigned char)*string[0]))
if (isdigit ((unsigned char)((*string)[0])))
{
weechat_string_dyn_concat (result, *string, 1);
(*string)++;
}
}
if ((*string[0] == ',') && (isdigit ((unsigned char)*string[1])))
if (((*string)[0] == ',')
&& (isdigit ((unsigned char)((*string)[1]))))
{
/* background */
weechat_string_dyn_concat (result, *string, 1);
(*string)++;
if (isdigit ((unsigned char)*string[0]))
if (isdigit ((unsigned char)((*string)[0])))
{
weechat_string_dyn_concat (result, *string, 1);
(*string)++;