diff mbox series

[FFmpeg-devel,1/2] avformat/hls: check return value of new_init_section()

Message ID 20210410100836.30145-1-cus@passwd.hu
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/hls: check return value of new_init_section() | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Marton Balint April 10, 2021, 10:08 a.m. UTC
Fixes part of ticket #8931.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavformat/hls.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andreas Rheinhardt April 10, 2021, 11:07 a.m. UTC | #1
Marton Balint:
> Fixes part of ticket #8931.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavformat/hls.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 597bea7f25..b589ad2870 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -842,6 +842,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));
> 
This is not the only unchecked thing in this demuxer: Every use of
dynarray_add contains one.

- Andreas
Marton Balint April 10, 2021, 1:07 p.m. UTC | #2
On Sat, 10 Apr 2021, Andreas Rheinhardt wrote:

> Marton Balint:
>> Fixes part of ticket #8931.
>> 
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavformat/hls.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>> 
>> diff --git a/libavformat/hls.c b/libavformat/hls.c
>> index 597bea7f25..b589ad2870 100644
>> --- a/libavformat/hls.c
>> +++ b/libavformat/hls.c
>> @@ -842,6 +842,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));
>> 
> This is not the only unchecked thing in this demuxer: Every use of
> dynarray_add contains one.

True, but preferably a new ticket should be opened for that, as that seems 
like a bigger task to fix properly, and the original ticket did not 
mention that.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 597bea7f25..b589ad2870 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -842,6 +842,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));