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

lavfi/show_palette: 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. Unfortunately, even leaving aside this subtle intermediate
failure aspect, commit 8087632027 was only
partially successful in addressing memleaks. Hopefully, this commit
fixes the issue completely.

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

Fixes: CID 1270818.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
This commit is contained in:
Ganesh Ajjanagadde 2015-12-04 01:46:07 -05:00
parent cb93df0dcb
commit 00c3220149

View File

@ -50,14 +50,22 @@ static int query_formats(AVFilterContext *ctx)
AVFilterFormats *in = ff_make_format_list(in_fmts); AVFilterFormats *in = ff_make_format_list(in_fmts);
AVFilterFormats *out = ff_make_format_list(out_fmts); AVFilterFormats *out = ff_make_format_list(out_fmts);
if (!in || !out) { if (!in || !out) {
av_freep(&in); ret = AVERROR(ENOMEM);
av_freep(&out); goto fail;
return AVERROR(ENOMEM);
} }
if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 || if ((ret = ff_formats_ref(in , &ctx->inputs[0]->out_formats)) < 0 ||
(ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0) (ret = ff_formats_ref(out, &ctx->outputs[0]->in_formats)) < 0)
return ret; goto fail;
return 0; return 0;
fail:
if (in)
av_freep(&in->formats);
av_freep(&in);
if (out)
av_freep(&out->formats);
av_freep(&out);
return ret;
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)