[FFmpeg-devel] [PATCH 2/2] avformat/mov: Free memory before returning in update_frag_index, when streams lack track id.

Michael Niedermayer michael at niedermayer.cc
Sat Jan 11 15:27:23 EET 2020


From: Thomas Guilbert <tguilbert at chromium.org>

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavformat/mov.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 75f098af09..c49fd4d43f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1327,8 +1327,10 @@ static int update_frag_index(MOVContext *c, int64_t offset)
 
     for (i = 0; i < c->fc->nb_streams; i++) {
         // Avoid building frag index if streams lack track id.
-        if (c->fc->streams[i]->id < 0)
+        if (c->fc->streams[i]->id < 0) {
+            av_freep(&frag_stream_info);
             return AVERROR_INVALIDDATA;
+        }
 
         frag_stream_info[i].id = c->fc->streams[i]->id;
         frag_stream_info[i].sidx_pts = AV_NOPTS_VALUE;
-- 
2.24.0



More information about the ffmpeg-devel mailing list