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

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


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

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 65937120d5..b9e2e8a04d 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1024,7 +1024,12 @@ static int parse_playlist(HLSContext *c, const char *url,
                 }
                 seg->duration = duration;
                 seg->key_type = key_type;
-                dynarray_add(&pls->segments, &pls->n_segments, seg);
+                if (av_dynarray_add_nofree(&pls->segments, &pls->n_segments,
+                                           seg) < 0) {
+                    free_segment(seg);
+                    ret = AVERROR(ENOMEM);
+                    goto fail;
+                }
                 is_segment = 0;
 
                 seg->size = seg_size;
-- 
2.31.1



More information about the ffmpeg-devel mailing list