From b539c0a1c062d61eab279e749df729788bd2bf93 Mon Sep 17 00:00:00 2001 From: Chris Lee <@klee93> Date: Tue, 25 Sep 2018 19:55:55 +0000 Subject: [PATCH] fix crash if bad config path given #719 --- src/init.c | 3 ++- src/util/timer.c | 3 ++- src/util/timer.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index 9104a08..8b2907a 100644 --- a/src/init.c +++ b/src/init.c @@ -247,8 +247,9 @@ void init(int argc, char **argv) if (!config_read()) { fprintf(stderr, "tint2: Could not read config file.\n"); print_usage(); + warnings_for_timers = false; cleanup(); - return; + exit(EXIT_FAILURE); } init_post_config(); diff --git a/src/util/timer.c b/src/util/timer.c index 040dc2e..8c05798 100644 --- a/src/util/timer.c +++ b/src/util/timer.c @@ -25,6 +25,7 @@ #include "timer.h" #include "test.h" +bool warnings_for_timers = true; bool debug_timers = false; #define MOCK_ORIGIN 1000000 @@ -59,7 +60,7 @@ void init_timer(Timer *timer, const char *name) void destroy_timer(Timer *timer) { - if (!g_list_find(timers, timer)) { + if (warnings_for_timers && !g_list_find(timers, timer)) { fprintf(stderr, RED "tint2: Attempt to destroy nonexisting timer: %s" RESET "\n", timer->name_); return; } diff --git a/src/util/timer.h b/src/util/timer.h index ceeef4b..680906e 100644 --- a/src/util/timer.h +++ b/src/util/timer.h @@ -23,6 +23,7 @@ #include #include "bool.h" +extern bool warnings_for_timers; extern bool debug_timers; typedef void TimerCallback(void *arg);