summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-01-21 19:30:08 +0100
committerSebastien Helleu <flashcode@flashtux.org>2011-01-21 19:30:08 +0100
commitcc6bb607e09101df7769cf1ec46a9bf8a605dab0 (patch)
tree77eace769bf610fcce06ef8abe46264c92bfab4e /src/plugins/irc
parent1ca2261e95b3f9b9dee59df5ee8fad5e8d493873 (diff)
downloadweechat-cc6bb607e09101df7769cf1ec46a9bf8a605dab0.zip
Test return value of calls to sscanf function
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-color.c16
1 files changed, 11 insertions, 5 deletions
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",