Module: kamailio
Branch: master
Commit: 150e757ec0fdadeee7b0ce8b6362f1a01aa0c382
URL:
https://github.com/kamailio/kamailio/commit/150e757ec0fdadeee7b0ce8b6362f1a…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T14:51:48+02:00
db_mysql: use gmtime_r() for a safer multi-thread usage
---
Modified: src/modules/db_mysql/my_cmd.c
---
Diff:
https://github.com/kamailio/kamailio/commit/150e757ec0fdadeee7b0ce8b6362f1a…
Patch:
https://github.com/kamailio/kamailio/commit/150e757ec0fdadeee7b0ce8b6362f1a…
---
diff --git a/src/modules/db_mysql/my_cmd.c b/src/modules/db_mysql/my_cmd.c
index c12d649dd4..23dfb27f81 100644
--- a/src/modules/db_mysql/my_cmd.c
+++ b/src/modules/db_mysql/my_cmd.c
@@ -476,7 +476,7 @@ static int build_update_cmd(str* sql_cmd, db_cmd_t* cmd)
static inline void update_field(MYSQL_BIND *param, db_fld_t* fld)
{
struct my_fld* fp; /* field payload */
- struct tm* t;
+ struct tm t;
fp = DB_GET_PAYLOAD(fld);
@@ -524,13 +524,13 @@ static inline void update_field(MYSQL_BIND *param, db_fld_t* fld)
break;
case DB_DATETIME:
- t = gmtime(&fld->v.time);
- fp->time.second = t->tm_sec;
- fp->time.minute = t->tm_min;
- fp->time.hour = t->tm_hour;
- fp->time.day = t->tm_mday;
- fp->time.month = t->tm_mon + 1;
- fp->time.year = t->tm_year + 1900;
+ gmtime_r(&fld->v.time, &t);
+ fp->time.second = t.tm_sec;
+ fp->time.minute = t.tm_min;
+ fp->time.hour = t.tm_hour;
+ fp->time.day = t.tm_mday;
+ fp->time.month = t.tm_mon + 1;
+ fp->time.year = t.tm_year + 1900;
break;
case DB_NONE: