[FFmpeg-cvslog] wtv: Check the return value from gmtime

Martin Storsjö git at videolan.org
Mon Jun 25 17:57:16 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Sat Jun 23 21:46:26 2012 +0300| [dc5385806339f90b4eb074d9002205ebb4010cc2] | committer: Martin Storsjö

wtv: Check the return value from gmtime

On MSVC, gmtime returns NULL for values outside of their supported
range (and these show up in our fate test). This doesn't seem
to affect the actual fate test result.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc5385806339f90b4eb074d9002205ebb4010cc2
---

 libavformat/wtv.c |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/libavformat/wtv.c b/libavformat/wtv.c
index 07549b2..83f1bc1 100644
--- a/libavformat/wtv.c
+++ b/libavformat/wtv.c
@@ -443,7 +443,11 @@ 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;
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    struct tm *tm = gmtime(&t);
+    if (tm)
+        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    else
+        buf[0] = '\0';
 }
 
 /**
@@ -452,7 +456,11 @@ 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;
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    struct tm *tm = gmtime(&t);
+    if (tm)
+        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    else
+        buf[0] = '\0';
 }
 
 /**
@@ -461,7 +469,11 @@ 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);
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    struct tm *tm = gmtime(&t);
+    if (tm)
+        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    else
+        buf[0] = '\0';
 }
 
 static void get_attachment(AVFormatContext *s, AVIOContext *pb, int length)



More information about the ffmpeg-cvslog mailing list