about summary refs log tree commit diff
path: root/src/time
diff options
context:
space:
mode:
Diffstat (limited to 'src/time')
-rw-r--r--src/time/ctime_r.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/time/ctime_r.c b/src/time/ctime_r.c
index d2260a16..3e24aa68 100644
--- a/src/time/ctime_r.c
+++ b/src/time/ctime_r.c
@@ -2,7 +2,6 @@
 
 char *ctime_r(const time_t *t, char *buf)
 {
-	struct tm tm;
-	localtime_r(t, &tm);
-	return asctime_r(&tm, buf);
+	struct tm tm, *tm_p = localtime_r(t, &tm);
+	return tm_p ? asctime_r(tm_p, buf) : 0;
 }