1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

lavfi/af_amix: fix memory leak

Recent commits 6aaac24d72 and
3835554bf8 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: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
This commit is contained in:
Ganesh Ajjanagadde 2015-12-04 02:04:46 -05:00
parent 924fcac521
commit 89bbf01978

View File

@ -519,20 +519,23 @@ static int query_formats(AVFilterContext *ctx)
int ret; int ret;
layouts = ff_all_channel_layouts(); layouts = ff_all_channel_layouts();
if (!layouts) if (!layouts) {
return AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail;
}
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT)) < 0) if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT )) < 0 ||
return ret; (ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0 ||
if ((ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP)) < 0) (ret = ff_set_common_formats (ctx, formats)) < 0 ||
return ret; (ret = ff_set_common_channel_layouts(ctx, layouts)) < 0 ||
ret = ff_set_common_formats(ctx, formats); (ret = ff_set_common_samplerates(ctx, ff_all_samplerates())) < 0)
if (ret < 0) goto fail;
return ret; return 0;
ret = ff_set_common_channel_layouts(ctx, layouts); fail:
if (ret < 0) if (layouts)
return ret; av_freep(&layouts->channel_layouts);
return ff_set_common_samplerates(ctx, ff_all_samplerates()); av_freep(&layouts);
return ret;
} }
static const AVFilterPad avfilter_af_amix_outputs[] = { static const AVFilterPad avfilter_af_amix_outputs[] = {