ソースを参照

tmrec: use localtime_r() for a safer multi-thread usage

Victor Seva 5 年 前
コミット
92e2c22c3c
1 ファイル変更7 行追加7 行削除
  1. 7 7
      src/modules/tmrec/tmrec_mod.c

+ 7 - 7
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;