From ac3fe062bd9b429133ab086fc28e15b97421a092 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 4 May 2020 18:26:47 +0200 Subject: [PATCH] libs/srdb1: use thread safe localtime_r() (cherry picked from commit c01633dc54d8d4dc3b3bc2cab064f91a49c8257d) --- src/lib/srdb1/db_ut.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/srdb1/db_ut.c b/src/lib/srdb1/db_ut.c index 39ac11d3793..318b442e44b 100644 --- a/src/lib/srdb1/db_ut.c +++ b/src/lib/srdb1/db_ut.c @@ -350,7 +350,7 @@ int db_str2time(const char* _s, time_t* _v) */ int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode) { - struct tm* t; + struct tm t; int l; if ((!_s) || (!_l) || (*_l < 2)) { @@ -361,8 +361,8 @@ int db_time2str_ex(time_t _v, char* _s, int* _l, int _qmode) if(_qmode) *_s++ = '\''; /* Convert time_t structure to format accepted by the database */ - t = localtime(&_v); - l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", t); + localtime_r(&_v, &t); + l = strftime(_s, *_l -1, "%Y-%m-%d %H:%M:%S", &t); if (l == 0) { LM_ERR("Error during time conversion\n");