summaryrefslogtreecommitdiff
path: root/libavfilter/af_channelmap.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-04 00:49:55 -0500
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-09 07:58:13 -0500
commit924fcac52148ef3e37ea39b5901299930b9c1b28 (patch)
tree4bd07a43dad41927f58cb143d9eea96abbcbbabb /libavfilter/af_channelmap.c
parent31f0d555e07797df1a0a141fa5e022648d480a49 (diff)
lavfi/af_channelmap: fix memory leak
Recent commits 6aaac24d72a7da631173209841a3944fcb4a3309 and 3835554bf8ed78539a3492c239f979c0ab03a15f 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 1338330. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavfilter/af_channelmap.c')
-rw-r--r--libavfilter/af_channelmap.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 9e95a98d00..dcae2a21d9 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -292,14 +292,23 @@ static int channelmap_query_formats(AVFilterContext *ctx)
int ret;
layouts = ff_all_channel_layouts();
+ if (!layouts) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
if ((ret = ff_add_channel_layout (&channel_layouts, s->output_layout )) < 0 ||
(ret = ff_set_common_formats (ctx , ff_planar_sample_fmts() )) < 0 ||
(ret = ff_set_common_samplerates (ctx , ff_all_samplerates() )) < 0 ||
(ret = ff_channel_layouts_ref (layouts , &ctx->inputs[0]->out_channel_layouts)) < 0 ||
(ret = ff_channel_layouts_ref (channel_layouts , &ctx->outputs[0]->in_channel_layouts)) < 0)
- return ret;
+ goto fail;
return 0;
+fail:
+ if (layouts)
+ av_freep(&layouts->channel_layouts);
+ av_freep(&layouts);
+ return ret;
}
static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)