From 62a7faf5b2cabc4b2c225555df0b88eafc9528e4 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 22 Feb 2001 08:35:53 +0000 Subject: strip_real_length(): initialize last_color_pos and last_color_len to -1. Word hilighting crashed if there was no colors set in the line.. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1282 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/hilight-text.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/fe-common/core/hilight-text.c') diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index c85e1ced..a506549b 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -447,10 +447,12 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *str) /* end of the line */ pos = strip_real_length(str, next_hilight_end, &color_pos, &color_len); - lastcolor = g_strndup(str+color_pos, color_len); - g_string_append(tmp, lastcolor); - g_string_append(tmp, str+pos); - g_free(lastcolor); + if (color_pos > 0) { + lastcolor = g_strndup(str+color_pos, color_len); + g_string_append(tmp, lastcolor); + g_string_append(tmp, str+pos); + g_free(lastcolor); + } newstr = tmp->str; g_string_free(tmp, FALSE); -- cgit v1.2.3