diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/aspell/weechat-aspell.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-color.c | 16 | ||||
-rw-r--r-- | src/plugins/scripts/script.c | 7 |
3 files changed, 21 insertions, 9 deletions
diff --git a/src/plugins/aspell/weechat-aspell.c b/src/plugins/aspell/weechat-aspell.c index 498ac1183..698657293 100644 --- a/src/plugins/aspell/weechat-aspell.c +++ b/src/plugins/aspell/weechat-aspell.c @@ -676,7 +676,7 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, const char *color_normal, *color_error; int utf8_char_int, char_size; int length, index_result, length_word, word_ok; - int length_color_normal, length_color_error; + int length_color_normal, length_color_error, rc; /* make C compiler happy */ (void) data; @@ -685,7 +685,10 @@ weechat_aspell_modifier_cb (void *data, const char *modifier, if (!string || !string[0]) return NULL; - sscanf (modifier_data, "%lx", &value); + rc = sscanf (modifier_data, "%lx", &value); + if ((rc == EOF) || (rc == 0)) + return NULL; + buffer = (struct t_gui_buffer *)value; if (!weechat_aspell_spellers) diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c index b8dfd36b2..6afa011a1 100644 --- a/src/plugins/irc/irc-color.c +++ b/src/plugins/irc/irc-color.c @@ -65,7 +65,7 @@ irc_color_decode (const char *string, int keep_colors) unsigned char *out, *ptr_string; int out_length, length, out_pos; char str_fg[3], str_bg[3], str_color[128]; - int fg, bg, bold, reverse, italic, underline; + int fg, bg, bold, reverse, italic, underline, rc; out_length = (strlen (string) * 2) + 1; out = malloc (out_length); @@ -164,13 +164,19 @@ irc_color_decode (const char *string, int keep_colors) bg = -1; if (str_fg[0]) { - sscanf (str_fg, "%d", &fg); - fg %= IRC_NUM_COLORS; + rc = sscanf (str_fg, "%d", &fg); + if ((rc != EOF) && (rc >= 1)) + { + fg %= IRC_NUM_COLORS; + } } if (str_bg[0]) { - sscanf (str_bg, "%d", &bg); - bg %= IRC_NUM_COLORS; + rc = sscanf (str_bg, "%d", &bg); + if ((rc != EOF) && (rc >= 1)) + { + bg %= IRC_NUM_COLORS; + } } snprintf (str_color, sizeof (str_color), "%s%s%s", diff --git a/src/plugins/scripts/script.c b/src/plugins/scripts/script.c index bcccfec89..8f36e2106 100644 --- a/src/plugins/scripts/script.c +++ b/src/plugins/scripts/script.c @@ -386,13 +386,16 @@ void * script_str2ptr (const char *pointer_str) { long unsigned int value; + int rc; if (!pointer_str || (pointer_str[0] != '0') || (pointer_str[1] != 'x')) return NULL; - sscanf (pointer_str + 2, "%lx", &value); + rc = sscanf (pointer_str + 2, "%lx", &value); + if ((rc != EOF) && (rc >= 1)) + return (void *)value; - return (void *)value; + return NULL; } /* |