]> git.sur5r.net Git - i3/i3status/commitdiff
Do proper error handling in print_time()
authorAxel Wagner <mail@merovius.de>
Thu, 17 Jun 2010 19:33:28 +0000 (21:33 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 19 Jun 2010 10:44:19 +0000 (12:44 +0200)
src/print_time.c

index 68714372bd1acc2bf5c05350dd52052c0d81a798..2cf2ab3ad22e8bb73f69f0b6865cf6af0d1ea5c1 100644 (file)
@@ -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(&current_time);
+        if (current_tm == NULL) {
+                return;
+        }
         (void)strftime(part, sizeof(part), format, current_tm);
         printf("%s", part);
 }