summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Wagner <mail@merovius.de>2010-06-17 21:33:28 +0200
committerMichael Stapelberg <michael@stapelberg.de>2010-06-19 12:44:19 +0200
commitda595ee9f7cc487b02109e992e4b2f3f27f78d5a (patch)
tree18dcceb94413bdcd25a23fa55b72a863865830b6
parent09967274d72e4cb134b432da43511e8a96683855 (diff)
Do proper error handling in print_time()
-rw-r--r--src/print_time.c6
1 files changed, 6 insertions, 0 deletions
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(&current_time);
+ if (current_tm == NULL) {
+ return;
+ }
(void)strftime(part, sizeof(part), format, current_tm);
printf("%s", part);
}