Browse Source

lavfi/af_channelmap: 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 1338330.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
tags/n3.0
Ganesh Ajjanagadde 10 years ago
parent
commit
924fcac521
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      libavfilter/af_channelmap.c

+ 10
- 1
libavfilter/af_channelmap.c View File

@@ -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)


Loading…
Cancel
Save