summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fe-common/core/formats.c5
-rw-r--r--src/fe-common/core/hilight-text.c10
2 files changed, 11 insertions, 4 deletions
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 7faf3d2a..2ef4aad1 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -630,6 +630,11 @@ int strip_real_length(const char *str, int len,
{
const char *start = str;
+ if (last_color_pos != NULL)
+ *last_color_pos = -1;
+ if (last_color_len != NULL)
+ *last_color_len = -1;
+
while (*str != '\0') {
if (*str == 3) {
const char *mircstart = str;
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);