]> git.sesse.net Git - ffmpeg/commitdiff
movenc: Keep writing zero-entry stts atoms as intended
authorMartin Storsjö <martin@martin.st>
Fri, 6 Mar 2015 10:27:14 +0000 (12:27 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 6 Mar 2015 14:17:48 +0000 (16:17 +0200)
a876585215 had the unintended side effect of returning AVERROR(ENOMEM)
when track->entry is zero, while the code intentionally wants to
continue in that case.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/movenc.c

index 585b080b5bc6f528d3a7b4c45e350ed48cf61c51..343f321e2b62c3c3c7474293915d5c25d6591574 100644 (file)
@@ -1197,7 +1197,7 @@ static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
 /* Time to sample atom */
 static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
 {
-    MOVStts *stts_entries;
+    MOVStts *stts_entries = NULL;
     uint32_t entries = -1;
     uint32_t atom_size;
     int i;
@@ -1210,11 +1210,11 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
         stts_entries[0].duration = 1;
         entries = 1;
     } else {
-        stts_entries = track->entry ?
-                       av_malloc(track->entry * sizeof(*stts_entries)) : /* worst case */
-                       NULL;
-        if (!stts_entries)
-            return AVERROR(ENOMEM);
+        if (track->entry) {
+            stts_entries = av_malloc(track->entry * sizeof(*stts_entries)); /* worst case */
+            if (!stts_entries)
+                return AVERROR(ENOMEM);
+        }
         for (i = 0; i < track->entry; i++) {
             int duration = get_cluster_duration(track, i);
             if (i && duration == stts_entries[entries].duration) {