From 2b8aa56917ca63448b43f44cc23f2f36aa7918e8 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 24 Aug 2008 09:12:06 +0200 Subject: Fix crash with filters and day change lines --- src/gui/gui-chat.c | 3 ++- src/gui/gui-color.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 87fde2fe1..5f3f136d1 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -532,7 +532,8 @@ gui_chat_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix, match_prefix = 1; match_message = 1; - prefix = (char *)gui_color_decode ((unsigned char *)line->prefix); + prefix = (line->prefix) ? + (char *)gui_color_decode ((unsigned char *)line->prefix) : NULL; if (prefix && regex_prefix) { if (regexec (regex_prefix, prefix, 0, NULL, 0) != 0) diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 6b5db98f2..dc77acaa9 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -235,6 +235,9 @@ gui_color_decode (const unsigned char *string) unsigned char *out; int out_length, out_pos, length; + if (!string) + return NULL; + out_length = (strlen ((char *)string) * 2) + 1; out = malloc (out_length); if (!out) @@ -294,8 +297,11 @@ gui_color_decode (const unsigned char *string) void gui_color_free (struct t_gui_color *color) { - if (color->string) - free (color->string); - - free (color); + if (color) + { + if (color->string) + free (color->string); + + free (color); + } } -- cgit v1.2.3