From a2266e4e3f981d294800a877c5808362841c91b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Thu, 19 Nov 2020 22:20:48 +0100 Subject: [PATCH] core: add missing cast to unsigned char on first argument to function isdigit --- src/gui/gui-color.c | 13 +++++++++---- src/plugins/spell/spell.c | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index bc43ac44e..6aae528c3 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -683,9 +683,11 @@ gui_color_code_size (const char *string) break; case GUI_COLOR_EXTENDED_CHAR: ptr_string++; - if ((isdigit (ptr_string[0])) && (isdigit (ptr_string[1])) - && (isdigit (ptr_string[2])) && (isdigit (ptr_string[3])) - && (isdigit (ptr_string[4]))) + if ((isdigit ((unsigned char)ptr_string[0])) + && (isdigit ((unsigned char)ptr_string[1])) + && (isdigit ((unsigned char)ptr_string[2])) + && (isdigit ((unsigned char)ptr_string[3])) + && (isdigit ((unsigned char)ptr_string[4]))) { ptr_string += 5; } @@ -713,8 +715,11 @@ gui_color_code_size (const char *string) ptr_string++; break; default: - if (isdigit (ptr_string[0]) && isdigit (ptr_string[1])) + if (isdigit ((unsigned char)ptr_string[0]) + && isdigit ((unsigned char)ptr_string[1])) + { ptr_string += 2; + } break; } return ptr_string - string; diff --git a/src/plugins/spell/spell.c b/src/plugins/spell/spell.c index e9278e995..821fdcdd7 100644 --- a/src/plugins/spell/spell.c +++ b/src/plugins/spell/spell.c @@ -679,23 +679,23 @@ spell_skip_color_codes (char **string, char **result) /* IRC color code */ weechat_string_dyn_concat (result, *string, 1); (*string)++; - if (isdigit (*string[0])) + if (isdigit ((unsigned char)*string[0])) { /* foreground */ weechat_string_dyn_concat (result, *string, 1); (*string)++; - if (isdigit (*string[0])) + if (isdigit ((unsigned char)*string[0])) { weechat_string_dyn_concat (result, *string, 1); (*string)++; } } - if ((*string[0] == ',') && (isdigit (*string[1]))) + if ((*string[0] == ',') && (isdigit ((unsigned char)*string[1]))) { /* background */ weechat_string_dyn_concat (result, *string, 1); (*string)++; - if (isdigit (*string[0])) + if (isdigit ((unsigned char)*string[0])) { weechat_string_dyn_concat (result, *string, 1); (*string)++;