diff mbox series

[FFmpeg-devel,2/2] avfilter/af_mcompand: check allocation results

Message ID 20210410100836.30145-2-cus@passwd.hu
State Accepted
Commit 46f3ae8f672533a380dea7c4e13c84d52014de6c
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 the only remaining part of ticket #8931.

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

Comments

Andreas Rheinhardt April 10, 2021, 11:04 a.m. UTC | #1
Marton Balint:
> Fixes the only remaining part of ticket #8931.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavfilter/af_mcompand.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c
> index ce4f366ad7..d1a3dc123a 100644
> --- a/libavfilter/af_mcompand.c
> +++ b/libavfilter/af_mcompand.c
> @@ -384,6 +384,9 @@ static int config_output(AVFilterLink *outlink)
>          s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double));
>          s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double));
>          s->bands[i].volume = av_calloc(outlink->channels, sizeof(double));
> +        if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || !s->bands[i].volume)
> +            return AVERROR(ENOMEM);
> +
>          for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) {
>              char *tstr3 = av_strtok(p3, ",", &saveptr3);
>  
> 
You are not the first one:
https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/270956.html (I
haven't applied this as I thought that Paul as the author/maintainer
should do so.)

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

> Marton Balint:
>> Fixes the only remaining part of ticket #8931.
>> 
>> Signed-off-by: Marton Balint <cus@passwd.hu>
>> ---
>>  libavfilter/af_mcompand.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c
>> index ce4f366ad7..d1a3dc123a 100644
>> --- a/libavfilter/af_mcompand.c
>> +++ b/libavfilter/af_mcompand.c
>> @@ -384,6 +384,9 @@ static int config_output(AVFilterLink *outlink)
>>          s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double));
>>          s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double));
>>          s->bands[i].volume = av_calloc(outlink->channels, sizeof(double));
>> +        if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || !s->bands[i].volume)
>> +            return AVERROR(ENOMEM);
>> +
>>          for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) {
>>              char *tstr3 = av_strtok(p3, ",", &saveptr3);
>> 
>> 
> You are not the first one:
> https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/270956.html (I
> haven't applied this as I thought that Paul as the author/maintainer
> should do so.)

If the maintainer does not seem interested then it is OK to apply, 
especially if it looks trivial. So feel free to apply whichever version 
you prefer.

Thanks,
Marton
Marton Balint April 18, 2021, 10:09 a.m. UTC | #3
On Sat, 10 Apr 2021, Marton Balint wrote:

>
>
> On Sat, 10 Apr 2021, Andreas Rheinhardt wrote:
>
>> Marton Balint:
>>> Fixes the only remaining part of ticket #8931.
>>> 
>>> Signed-off-by: Marton Balint <cus@passwd.hu>
>>> ---
>>>  libavfilter/af_mcompand.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>> 
>>> diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c
>>> index ce4f366ad7..d1a3dc123a 100644
>>> --- a/libavfilter/af_mcompand.c
>>> +++ b/libavfilter/af_mcompand.c
>>> @@ -384,6 +384,9 @@ static int config_output(AVFilterLink *outlink)
>>>          s->bands[i].attack_rate = av_calloc(outlink->channels, 
> sizeof(double));
>>>          s->bands[i].decay_rate = av_calloc(outlink->channels, 
> sizeof(double));
>>>          s->bands[i].volume = av_calloc(outlink->channels, 
> sizeof(double));
>>> +        if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || 
> !s->bands[i].volume)
>>> +            return AVERROR(ENOMEM);
>>> +
>>>          for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) {
>>>              char *tstr3 = av_strtok(p3, ",", &saveptr3);
>>> 
>>> 
>> You are not the first one:
>> https://ffmpeg.org/pipermail/ffmpeg-devel/2020-October/270956.html (I
>> haven't applied this as I thought that Paul as the author/maintainer
>> should do so.)
>
> If the maintainer does not seem interested then it is OK to apply, 
> especially if it looks trivial. So feel free to apply whichever version 
> you prefer.

Will push this series soon.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c
index ce4f366ad7..d1a3dc123a 100644
--- a/libavfilter/af_mcompand.c
+++ b/libavfilter/af_mcompand.c
@@ -384,6 +384,9 @@  static int config_output(AVFilterLink *outlink)
         s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double));
         s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double));
         s->bands[i].volume = av_calloc(outlink->channels, sizeof(double));
+        if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || !s->bands[i].volume)
+            return AVERROR(ENOMEM);
+
         for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) {
             char *tstr3 = av_strtok(p3, ",", &saveptr3);