summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-11-20 21:50:05 +0100
committerSébastien Helleu <flashcode@flashtux.org>2020-11-20 21:50:05 +0100
commitee24fac586201351adf6ce6dfad4e8c980129878 (patch)
tree295d7d95ab1d01b292f61cefa3047a2636202a75
parenta2266e4e3f981d294800a877c5808362841c91b5 (diff)
downloadweechat-ee24fac586201351adf6ce6dfad4e8c980129878.zip
spell: fix crash with IRC color codes in command line (closes #1589)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/spell/spell.c19
2 files changed, 11 insertions, 9 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index a907b4696..4e62e87c8 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -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]]
diff --git a/src/plugins/spell/spell.c b/src/plugins/spell/spell.c
index 821fdcdd7..868e3f12c 100644
--- a/src/plugins/spell/spell.c
+++ b/src/plugins/spell/spell.c
@@ -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)++;