Fix #281 bad free. Also fix a memory leak. (#282)

* Fix #281 bad free. Also fix a memory leak.

With `n->icon = r->new_icon` and later `free(n->icon)`
`r->new_icon` is wrongly freed. Fix that with strdup.
Also fix an obvious memory leak by the way.
This commit is contained in:
John Chen 2017-01-21 14:38:36 +08:00 committed by Nikos Tsipinakis
parent dd4deb3b00
commit 1e477395d9

View File

@ -19,8 +19,11 @@ void rule_apply(rule_t * r, notification * n)
n->allow_markup = r->allow_markup; n->allow_markup = r->allow_markup;
if (r->plain_text != -1) if (r->plain_text != -1)
n->plain_text = r->plain_text; n->plain_text = r->plain_text;
if (r->new_icon) if (r->new_icon) {
n->icon = r->new_icon; if(n->icon)
g_free(n->icon);
n->icon = g_strdup(r->new_icon);
}
if (r->fg) if (r->fg)
n->color_strings[ColFG] = r->fg; n->color_strings[ColFG] = r->fg;
if (r->bg) if (r->bg)