Commit 31f0d555 authored by Ganesh Ajjanagadde's avatar Ganesh Ajjanagadde

lavfi/vf_alphamerge: fix memory leaks

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 1338326, 1338329.
Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
parent 301c2784
......@@ -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)
......
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