In mov demuxer, check that gmtime returns a valid value, fix crash, issue #2490
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>
Wed, 5 Jan 2011 19:21:04 +0000 (19:21 +0000)
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>
Wed, 5 Jan 2011 19:21:04 +0000 (19:21 +0000)
Originally committed as revision 26228 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/mov.c

index 2ceb21c..b602221 100644 (file)
@@ -591,8 +591,11 @@ static void mov_metadata_creation_time(AVMetadata **metadata, time_t time)
 {
     char buffer[32];
     if (time) {
+        struct tm *ptm;
         time -= 2082844800;  /* seconds between 1904-01-01 and Epoch */
-        strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", gmtime(&time));
+        ptm = gmtime(&time);
+        if (!ptm) return;
+        strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
         av_metadata_set2(metadata, "creation_time", buffer, 0);
     }
 }