[FFmpeg-devel] [PATCH 02/10] avformat/hls: fix leak of init section when dynarray_add fail
Zhao Zhili
quinkblack at foxmail.com
Tue Apr 12 11:15:14 EEST 2022
When av_dynarray_add failed, pls->init_sections will be freed,
which leads to leak of all entries of pls->init_sections.
---
libavformat/hls.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 67c9650e0b..e249810bce 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -463,7 +463,13 @@ static struct segment *get_init_section(struct playlist *pls,
av_free(sec_ptr);
return NULL;
}
- dynarray_add(&pls->init_sections, &pls->n_init_sections, sec_ptr);
+ if (av_dynarray_add_nofree(&pls->init_sections,
+ &pls->n_init_sections,
+ sec_ptr) < 0) {
+ av_free(sec_ptr->url);
+ av_free(sec_ptr);
+ return NULL;
+ }
return sec_ptr;
}
--
2.31.1
More information about the ffmpeg-devel
mailing list