aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/parseutils.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2014-10-24 10:46:36 +0300
committerMartin Storsjö <martin@martin.st>2014-10-26 00:14:54 +0300
commit82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de (patch)
tree5176e09d9c0cd74ddb5296be54fdb4fabca77c91 /libavutil/parseutils.c
parent3f8f1c6ff24ee858eb5b0bf47ef6d4605299a87e (diff)
downloadffmpeg-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 'libavutil/parseutils.c')
-rw-r--r--libavutil/parseutils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 414cd47e66..1ca0086adf 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -29,6 +29,7 @@
#include "eval.h"
#include "log.h"
#include "random_seed.h"
+#include "time_internal.h"
#include "parseutils.h"
typedef struct {
@@ -483,7 +484,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
{
const char *p;
int64_t t;
- struct tm dt = { 0 };
+ struct tm dt = { 0 }, tmbuf;
int i;
static const char * const date_fmt[] = {
"%Y-%m-%d",
@@ -527,9 +528,9 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
* current year-month-day time */
if (!q) {
if (is_utc) {
- dt = *gmtime(&now);
+ dt = *gmtime_r(&now, &tmbuf);
} else {
- dt = *localtime(&now);
+ dt = *localtime_r(&now, &tmbuf);
}
dt.tm_hour = dt.tm_min = dt.tm_sec = 0;
} else {