fix crash if bad config path given #719

This commit is contained in:
Chris Lee 2018-09-25 19:55:55 +00:00
parent 970c597796
commit b539c0a1c0
3 changed files with 5 additions and 2 deletions

View file

@ -247,8 +247,9 @@ void init(int argc, char **argv)
if (!config_read()) { if (!config_read()) {
fprintf(stderr, "tint2: Could not read config file.\n"); fprintf(stderr, "tint2: Could not read config file.\n");
print_usage(); print_usage();
warnings_for_timers = false;
cleanup(); cleanup();
return; exit(EXIT_FAILURE);
} }
init_post_config(); init_post_config();

View file

@ -25,6 +25,7 @@
#include "timer.h" #include "timer.h"
#include "test.h" #include "test.h"
bool warnings_for_timers = true;
bool debug_timers = false; bool debug_timers = false;
#define MOCK_ORIGIN 1000000 #define MOCK_ORIGIN 1000000
@ -59,7 +60,7 @@ void init_timer(Timer *timer, const char *name)
void destroy_timer(Timer *timer) 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_); fprintf(stderr, RED "tint2: Attempt to destroy nonexisting timer: %s" RESET "\n", timer->name_);
return; return;
} }

View file

@ -23,6 +23,7 @@
#include <sys/time.h> #include <sys/time.h>
#include "bool.h" #include "bool.h"
extern bool warnings_for_timers;
extern bool debug_timers; extern bool debug_timers;
typedef void TimerCallback(void *arg); typedef void TimerCallback(void *arg);