diff --git a/src/notification.c b/src/notification.c index 7ae2254..5250375 100644 --- a/src/notification.c +++ b/src/notification.c @@ -214,6 +214,9 @@ void notification_free(notification *n) g_free(n->category); g_free(n->text_to_render); g_free(n->urls); + g_free(n->colors[ColFG]); + g_free(n->colors[ColBG]); + g_free(n->colors[ColFrame]); actions_free(n->actions); rawimage_free(n->raw_icon); @@ -312,11 +315,11 @@ void notification_init(notification *n) /* Color hints */ if (!n->colors[ColFG]) - n->colors[ColFG] = xctx.colors[ColFG][n->urgency]; + n->colors[ColFG] = g_strdup(xctx.colors[ColFG][n->urgency]); if (!n->colors[ColBG]) - n->colors[ColBG] = xctx.colors[ColBG][n->urgency]; + n->colors[ColBG] = g_strdup(xctx.colors[ColBG][n->urgency]); if (!n->colors[ColFrame]) - n->colors[ColFrame] = xctx.colors[ColFrame][n->urgency]; + n->colors[ColFrame] = g_strdup(xctx.colors[ColFrame][n->urgency]); /* Sanitize misc hints */ if (n->progress < 0 || n->progress > 100) diff --git a/src/notification.h b/src/notification.h index c83077a..5b05e8a 100644 --- a/src/notification.h +++ b/src/notification.h @@ -55,8 +55,8 @@ typedef struct _notification { enum markup_mode markup; const char *format; - const char *colors[3]; const char *script; + char *colors[3]; /* Hints */ bool transient; /* timeout albeit user is idle */ diff --git a/src/rules.c b/src/rules.c index da64f9b..7be1abb 100644 --- a/src/rules.c +++ b/src/rules.c @@ -28,10 +28,14 @@ void rule_apply(rule_t *r, notification *n) rawimage_free(n->raw_icon); n->raw_icon = NULL; } - if (r->fg) - n->colors[ColFG] = r->fg; - if (r->bg) - n->colors[ColBG] = r->bg; + if (r->fg) { + g_free(n->colors[ColFG]); + n->colors[ColFG] = g_strdup(r->fg); + } + if (r->bg) { + g_free(n->colors[ColBG]); + n->colors[ColBG] = g_strdup(r->bg); + } if (r->format) n->format = r->format; if (r->script)