From ce57055a3a81c69603a1710caa70c94f10c7b4d9 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Mon, 31 Aug 2009 14:17:29 +0400 Subject: [PATCH] Ticket #1574: mc crashes while setting tty colors MC crashes if color sring containes an empty color name like following: base_color=normal=,default: Signed-off-by: Andrew Borodin --- src/tty/color.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tty/color.c b/src/tty/color.c index 3cd8e128c..c3f76c76b 100644 --- a/src/tty/color.c +++ b/src/tty/color.c @@ -75,14 +75,21 @@ configure_colors_string (const char *the_color_string) p = color_strings; while ((p != NULL) && (*p != NULL)) { - char **cfb; /* color, fore, back*/ + char **cfb; /* color, fore, back */ /* cfb[0] - entry name * cfb[1] - fore color - * cfb[20 - back color + * cfb[2] - back color */ char *e; cfb = g_strsplit_set (*p, "=,", 3); + p++; + + if (cfb[0] == NULL) { + g_strfreev (cfb); + continue; + } + /* append '=' to the entry name */ e = g_strdup_printf ("%s=", cfb[0]); g_free (cfb[0]); @@ -102,7 +109,6 @@ configure_colors_string (const char *the_color_string) } g_strfreev (cfb); - p++; } g_strfreev (color_strings);