[FFmpeg-devel] [PATCH 04/10] avformat/hls: fix leak of playlist when dynarray_add fail

Zhao Zhili quinkblack at foxmail.com
Tue Apr 12 11:15:16 EEST 2022


---
 libavformat/hls.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ecb6237d2e..d5c3009d07 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -330,7 +330,10 @@ static struct playlist *new_playlist(HLSContext *c, const char *url,
     pls->is_id3_timestamped = -1;
     pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
 
-    dynarray_add(&c->playlists, &c->n_playlists, pls);
+    if (av_dynarray_add_nofree(&c->playlists, &c->n_playlists, pls) < 0) {
+        free_playlist(c, pls);
+        return NULL;
+    }
     return pls;
 }
 
-- 
2.31.1



More information about the ffmpeg-devel mailing list