Module: kamailio Branch: master Commit: 92e2c22c3c709c3c9a5243b5d5bdd48293865b0c URL: https://github.com/kamailio/kamailio/commit/92e2c22c3c709c3c9a5243b5d5bdd48293865b0c
Author: Victor Seva <[email protected]> Committer: Victor Seva <[email protected]> Date: 2020-05-12T16:27:58+02:00 tmrec: use localtime_r() for a safer multi-thread usage --- Modified: src/modules/tmrec/tmrec_mod.c --- Diff: https://github.com/kamailio/kamailio/commit/92e2c22c3c709c3c9a5243b5d5bdd48293865b0c.diff Patch: https://github.com/kamailio/kamailio/commit/92e2c22c3c709c3c9a5243b5d5bdd48293865b0c.patch --- diff --git a/src/modules/tmrec/tmrec_mod.c b/src/modules/tmrec/tmrec_mod.c index 4bf21f9bad..cc97cc9b55 100644 --- a/src/modules/tmrec/tmrec_mod.c +++ b/src/modules/tmrec/tmrec_mod.c @@ -128,9 +128,9 @@ static void mod_destroy(void) static int w_is_leap_year(struct sip_msg* msg, char* t, char* str2) { time_t tv; - struct tm *tb; + struct tm tb; int y; - + if(msg==NULL) return -1; @@ -143,8 +143,8 @@ static int w_is_leap_year(struct sip_msg* msg, char* t, char* str2) } } else { tv = time(NULL); - tb = localtime(&tv); - y = 1900 + tb->tm_year; + localtime_r(&tv, &tb); + y = 1900 + tb.tm_year; } if(tr_is_leap_year(y)) @@ -155,12 +155,12 @@ static int w_is_leap_year(struct sip_msg* msg, char* t, char* str2) static int ki_is_leap_year_now(sip_msg_t* msg) { time_t tv; - struct tm *tb; + struct tm tb; int y; tv = time(NULL); - tb = localtime(&tv); - y = 1900 + tb->tm_year; + localtime_r(&tv, &tb); + y = 1900 + tb.tm_year; if(tr_is_leap_year(y)) return 1; _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
