From 30fa7d191e031797c182fcec93f20ae9124ea664 Mon Sep 17 00:00:00 2001 From: lbonn Date: Sat, 19 Oct 2019 16:05:42 +0200 Subject: Fix potential NULL reference on cleanup If allocation of bindings failed. Found with clang-tidy --- sway/config/bar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sway') diff --git a/sway/config/bar.c b/sway/config/bar.c index 9c30204e..f90fcdc0 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -39,8 +39,10 @@ void free_bar_config(struct bar_config *bar) { free(bar->swaybar_command); free(bar->font); free(bar->separator_symbol); - for (int i = 0; i < bar->bindings->length; i++) { - free_bar_binding(bar->bindings->items[i]); + if (bar->bindings) { + for (int i = 0; i < bar->bindings->length; i++) { + free_bar_binding(bar->bindings->items[i]); + } } list_free(bar->bindings); list_free_items_and_destroy(bar->outputs); -- cgit v1.2.3