[FFmpeg-devel] [PATCH] libavformat/hls: check new_init_section for null

Chris Miceli chris at miceli.net.au
Tue Oct 13 08:59:29 EEST 2020


new_init_section will return NULL under circumstances where the init
failed and this code needed to check for that. ret and goto fail are how
this is handled throughout the code.
---
 libavformat/hls.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 72e28ab94f..6c5c2f2061 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -828,6 +828,10 @@ static int parse_playlist(HLSContext *c, const char *url,
             ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_init_section_args,
                                &info);
             cur_init_section = new_init_section(pls, &info, url);
+            if (!cur_init_section) {
+                ret = AVERROR(ENOMEM);
+                goto fail;
+            }
             cur_init_section->key_type = key_type;
             if (has_iv) {
                 memcpy(cur_init_section->iv, iv, sizeof(iv));
-- 
2.28.0



More information about the ffmpeg-devel mailing list