@@ -70,10 +70,10 @@ static struct tm *time_to_tm(timestamp_t time, int tz)
return gmtime(&t);
}
-static struct tm *time_to_tm_local(timestamp_t time)
+static struct tm *time_to_tm_local(timestamp_t time, struct tm *tm)
{
time_t t = time;
- return localtime(&t);
+ return localtime_r(&t, tm);
}
/*
@@ -283,6 +283,7 @@ static void show_date_normal(struct strbuf *buf, timestamp_t time, struct tm *tm
const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
{
struct tm *tm;
+ struct tm tmbuf = { 0 };
struct tm human_tm = { 0 };
int human_tz = -1;
static struct strbuf timebuf = STRBUF_INIT;
@@ -318,7 +319,7 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
}
if (mode->local)
- tm = time_to_tm_local(time);
+ tm = time_to_tm_local(time, &tmbuf);
else
tm = time_to_tm(time, tz);
if (!tm) {
Phase out `localtime(3)' in favour of reentrant `localtime_r(3)' Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> --- date.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)