diff mbox series

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

Message ID tencent_C04DAECFA455682715B8FD163A4D6EA05F07@qq.com
State New
Headers show
Series [FFmpeg-devel,01/10] avformat/hls: fix repeated requests for media init section | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili April 12, 2022, 8:15 a.m. UTC
---
 libavformat/hls.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;