diff options
author | Martin Storsjö <martin@martin.st> | 2014-10-24 10:46:36 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2014-10-26 00:14:54 +0300 |
commit | 82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de (patch) | |
tree | 5176e09d9c0cd74ddb5296be54fdb4fabca77c91 /libavformat/wtv.c | |
parent | 3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e (diff) | |
download | ffmpeg-82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de.tar.gz |
Use gmtime_r instead of gmtime and localtime_r instead of localtime
gmtime isn't thread safe in general. In msvcrt (which lacks gmtime_r),
the buffer used by gmtime is thread specific though.
One call to localtime is left in avconv_opt.c, where thread safety
shouldn't matter (instead of making avconv depend on the libavutil
internal header).
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/wtv.c')
-rw-r--r-- | libavformat/wtv.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libavformat/wtv.c b/libavformat/wtv.c index 90984cfda0..5080d299ed 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -31,6 +31,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "libavutil/dict.h" +#include "libavutil/time_internal.h" #include "avformat.h" #include "internal.h" #include "riff.h" @@ -428,7 +429,8 @@ static int read_probe(AVProbeData *p) static void filetime_to_iso8601(char *buf, int buf_size, int64_t value) { time_t t = (value / 10000000LL) - 11644473600LL; - struct tm *tm = gmtime(&t); + struct tm tmbuf; + struct tm *tm = gmtime_r(&t, &tmbuf); if (tm) { if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) buf[0] = '\0'; @@ -442,7 +444,8 @@ static void filetime_to_iso8601(char *buf, int buf_size, int64_t value) static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value) { time_t t = (value / 10000000LL) - 719162LL*86400LL; - struct tm *tm = gmtime(&t); + struct tm tmbuf; + struct tm *tm = gmtime_r(&t, &tmbuf); if (tm) { if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) buf[0] = '\0'; @@ -456,7 +459,8 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value) static void oledate_to_iso8601(char *buf, int buf_size, int64_t value) { time_t t = 631112400LL + 86400*av_int2double(value); - struct tm *tm = gmtime(&t); + struct tm tmbuf; + struct tm *tm = gmtime_r(&t, &tmbuf); if (tm) { if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) buf[0] = '\0'; |