diff --git a/source/log.c b/source/log.c index a13b3a2..b995d0e 100644 --- a/source/log.c +++ b/source/log.c @@ -21,12 +21,13 @@ void WriteToLog(const char *fmt, ...) #else time_t unixTime = time(NULL); - struct tm *tStruct = localtime((const time_t *)&unixTime); + struct tm tStruct; + localtime_r(&unixTime, &tStruct); FILE *fp = fopen(CONFIG_PATH "log.txt", "a"); //Print time - fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", (tStruct->tm_year + 1900), tStruct->tm_mon, tStruct->tm_mday, tStruct->tm_hour, tStruct->tm_min, tStruct->tm_sec); + fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", (tStruct.tm_year + 1900), tStruct.tm_mon, tStruct.tm_mday, tStruct.tm_hour, tStruct.tm_min, tStruct.tm_sec); //Print the actual text va_list va;