Message ID | 20201013023047.59308-1-chris@miceli.net.au |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] libavfilter/af_mcompand: Check for failure to allocate memory | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | warning | Make failed |
Chris Miceli: > This commit fixes some unchecked memory allocations from #8931. > --- > libavfilter/af_mcompand.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c > index f142573bea..5309d884a5 100644 > --- a/libavfilter/af_mcompand.c > +++ b/libavfilter/af_mcompand.c > @@ -386,8 +386,17 @@ static int config_output(AVFilterLink *outlink) > } > > s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double)); > + if (!s->bands[i].attack_rate) { > + return AVERROR(ENOMEM); > + } > s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double)); > + if (!s->bands[i].decay_rate) { > + return AVERROR(ENOMEM); > + } > s->bands[i].volume = av_calloc(outlink->channels, sizeof(double)); > + if (!s->bands[i].volume) { > + return AVERROR(ENOMEM); > + } > for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) { > char *tstr3 = av_strtok(p3, ",", &saveptr3); > > The {} are unnecessary. - Andreas
diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c index f142573bea..5309d884a5 100644 --- a/libavfilter/af_mcompand.c +++ b/libavfilter/af_mcompand.c @@ -386,8 +386,17 @@ static int config_output(AVFilterLink *outlink) } s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].attack_rate) { + return AVERROR(ENOMEM); + } s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].decay_rate) { + return AVERROR(ENOMEM); + } s->bands[i].volume = av_calloc(outlink->channels, sizeof(double)); + if (!s->bands[i].volume) { + return AVERROR(ENOMEM); + } for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) { char *tstr3 = av_strtok(p3, ",", &saveptr3);