Skip to content

Commit 4fe05fe

Browse files
committed
Fix double free
1 parent be4f1bd commit 4fe05fe

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/notification.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ struct notification *notification_create(void)
458458
n->colors.fg = invalid;
459459
n->colors.bg = invalid;
460460
n->colors.frame = invalid;
461-
462461
n->colors.highlight = NULL;
463462

464463
n->script_run = false;

src/rules.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ void rule_free(struct rule *r)
241241
g_free(r->set_stack_tag);
242242
g_free(r->new_icon);
243243
g_free(r->name);
244+
245+
// Ugly but necessary
246+
if (r->highlight != settings.colors_low.highlight &&
247+
r->highlight != settings.colors_norm.highlight &&
248+
r->highlight != settings.colors_crit.highlight)
244249
gradient_free(r->highlight);
245250
}
246251

test/dbus.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,12 @@ TEST test_dbus_notify_colors(void)
760760

761761
// Invalid color strings are ignored
762762
ASSERTm("Invalid color strings should not change the color struct", COLOR_SAME(n->colors.bg, settings.colors_norm.bg));
763-
ASSERTm("Invalid color strings should not change the gradient struct", n->colors.highlight == settings.colors_norm.highlight);
763+
764+
ASSERTm("Invalid color strings should not change the gradient struct", n->colors.highlight->length == settings.colors_norm.highlight->length);
765+
766+
for (int i = 0; i < settings.colors_norm.highlight->length; i++)
767+
ASSERTm("Invalid color strings should not change the gradient struct",
768+
COLOR_SAME(n->colors.highlight->colors[i], settings.colors_norm.highlight->colors[i]));
764769

765770
dbus_notification_free(n_dbus);
766771

0 commit comments

Comments
 (0)