diff mbox

[FFmpeg-devel] avformat/movenc: free eac3 private data only when closing the stream

Message ID 20190329014131.13668-1-jamrial@gmail.com
State Accepted
Commit 27c94c57dc84da8125225fda7d241be57d19b391
Headers show

Commit Message

James Almer March 29, 2019, 1:41 a.m. UTC
This makes sure the data is available when writing the moov atom during the
second pass triggered by the faststart movflag.

Fixes ticket #7780

Signed-off-by: James Almer <jamrial@gmail.com>
---
This is why errors should always be propagated, or at least a warning printed
even if they are ignored.

 libavformat/movenc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

James Almer March 31, 2019, 9:04 p.m. UTC | #1
On 3/28/2019 10:41 PM, James Almer wrote:
> This makes sure the data is available when writing the moov atom during the
> second pass triggered by the faststart movflag.
> 
> Fixes ticket #7780

Will push soon.
diff mbox

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8969d5b170..26cb2e6ea1 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -552,8 +552,7 @@  static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
     size = 2 + ((34 * (info->num_ind_sub + 1) + 7) >> 3);
     buf = av_malloc(size);
     if (!buf) {
-        size = AVERROR(ENOMEM);
-        goto end;
+        return AVERROR(ENOMEM);
     }
 
     init_put_bits(&pbc, buf, size);
@@ -584,10 +583,6 @@  static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track)
 
     av_free(buf);
 
-end:
-    av_packet_unref(&info->pkt);
-    av_freep(&track->eac3_priv);
-
     return size;
 }
 
@@ -5973,6 +5968,11 @@  static void mov_free(AVFormatContext *s)
         av_freep(&mov->tracks[i].frag_info);
         av_packet_unref(&mov->tracks[i].cover_image);
 
+        if (mov->tracks[i].eac3_priv) {
+            struct eac3_info *info = mov->tracks[i].eac3_priv;
+            av_packet_unref(&info->pkt);
+            av_freep(&mov->tracks[i].eac3_priv);
+        }
         if (mov->tracks[i].vos_len)
             av_freep(&mov->tracks[i].vos_data);