summaryrefslogtreecommitdiff
path: root/libavfilter/vf_alphamerge.c
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-04 00:37:19 -0500
committerGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-12-09 07:58:03 -0500
commit31f0d555e07797df1a0a141fa5e022648d480a49 (patch)
tree6d0a65ab0df1fa80a932de1a94d6e6e728863dbc /libavfilter/vf_alphamerge.c
parent301c2784b35036945cd9a7049808deecce149916 (diff)
downloadffmpeg-31f0d555e07797df1a0a141fa5e022648d480a49.tar.gz
lavfi/vf_alphamerge: fix memory leaks
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 1338326, 1338329. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Diffstat (limited to 'libavfilter/vf_alphamerge.c')
-rw-r--r--libavfilter/vf_alphamerge.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c
index 8a1ca22da5..ecc114c3f3 100644
--- a/libavfilter/vf_alphamerge.c
+++ b/libavfilter/vf_alphamerge.c
@@ -61,13 +61,23 @@ static int query_formats(AVFilterContext *ctx)
int ret;
if (!(main_formats = ff_make_format_list(main_fmts)) ||
- !(alpha_formats = ff_make_format_list(alpha_fmts)))
- return AVERROR(ENOMEM);
+ !(alpha_formats = ff_make_format_list(alpha_fmts))) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
if ((ret = ff_formats_ref(main_formats , &ctx->inputs[0]->out_formats)) < 0 ||
(ret = ff_formats_ref(alpha_formats, &ctx->inputs[1]->out_formats)) < 0 ||
(ret = ff_formats_ref(main_formats , &ctx->outputs[0]->in_formats)) < 0)
- return ret;
+ goto fail;
return 0;
+fail:
+ if (main_formats)
+ av_freep(&main_formats->formats);
+ av_freep(&main_formats);
+ if (alpha_formats)
+ av_freep(&alpha_formats->formats);
+ av_freep(&alpha_formats);
+ return ret;
}
static int config_input_main(AVFilterLink *inlink)