From: Axel Wagner Date: Thu, 17 Jun 2010 19:33:28 +0000 (+0200) Subject: Do proper error handling in print_time() X-Git-Tag: 2.2~29 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=da595ee9f7cc487b02109e992e4b2f3f27f78d5a;p=i3%2Fi3status Do proper error handling in print_time() --- diff --git a/src/print_time.c b/src/print_time.c index 6871437..2cf2ab3 100644 --- a/src/print_time.c +++ b/src/print_time.c @@ -7,7 +7,13 @@ void print_time(const char *format) { static char part[512]; /* Get date & time */ time_t current_time = time(NULL); + if (current_time == (time_t) -1) { + return; + } struct tm *current_tm = localtime(¤t_time); + if (current_tm == NULL) { + return; + } (void)strftime(part, sizeof(part), format, current_tm); printf("%s", part); }