#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
+#include "libavutil/time_internal.h"
#include "avformat.h"
#include "internal.h"
#include "wtv.h"
static int 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)
return -1;
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+ return -1;
return 0;
}
static int 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)
return -1;
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+ return -1;
return 0;
}
static int oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = (av_int2double(value) - 25569.0) * 86400;
- struct tm *result= gmtime(&t);
- if (!result)
+ struct tm tmbuf;
+ struct tm *tm= gmtime_r(&t, &tmbuf);
+ if (!tm)
+ return -1;
+ if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
return -1;
- strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", result);
return 0;
}
avio_skip(s->pb, 4);
root_sector = avio_rl32(s->pb);
- seek_by_sector(s->pb, root_sector, 0);
+ ret = seek_by_sector(s->pb, root_sector, 0);
+ if (ret < 0)
+ return ret;
root_size = avio_read(s->pb, root, root_size);
if (root_size < 0)
return AVERROR_INVALIDDATA;