Commit 89bbf019 authored by Ganesh Ajjanagadde's avatar Ganesh Ajjanagadde

lavfi/af_amix: fix memory leak

Recent commits 6aaac24d and
3835554b made progress towards cleaning
up usage of the formats API, and in particular fixed possible NULL pointer
dereferences.

This commit addresses the issue of possible resource leaks when some intermediate
call fails.

Tested with valgrind --leak-check=full --show-leak-kinds=all, and manual simulation
of malloc/realloc failures.

Fixes: CID 1250334.
Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
parent 924fcac5
......@@ -519,20 +519,23 @@ static int query_formats(AVFilterContext *ctx)
int ret;
layouts = ff_all_channel_layouts();
if (!layouts)
return AVERROR(ENOMEM);
if (!layouts) {
ret = AVERROR(ENOMEM);
goto fail;
}
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT)) < 0)
return ret;
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0)
return ret;
ret = ff_set_common_formats(ctx, formats);
if (ret < 0)
return ret;
ret = ff_set_common_channel_layouts(ctx, layouts);
if (ret < 0)
return ret;
return ff_set_common_samplerates(ctx, ff_all_samplerates());
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 ||
(ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 ||
(ret = ff_set_common_formats (ctx, formats)) < 0 ||
(ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||
(ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
goto fail;
return 0;
fail:
if (layouts)
av_freep(&layouts->channel_layouts);
av_freep(&layouts);
return ret;
}
static const AVFilterPad avfilter_af_amix_outputs[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment