Message ID | AM7PR03MB6660A93C29EB8D527BEA09E88FA89@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | Accepted |
Commit | 22c4f3399133a62aa11f4af01e7dacea08d4ddae |
Headers | show |
Series | [FFmpeg-devel,1/3] avfilter/avfiltergraph: Simplify adding filter to graph | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 45b028cd9c..ee0c82030d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -183,17 +183,15 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, } } - s = ff_filter_alloc(filter, name); - if (!s) + filters = av_realloc_array(graph->filters, graph->nb_filters + 1, sizeof(*filters)); + if (!filters) return NULL; + graph->filters = filters; - filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1)); - if (!filters) { - avfilter_free(s); + s = ff_filter_alloc(filter, name); + if (!s) return NULL; - } - graph->filters = filters; graph->filters[graph->nb_filters++] = s; s->graph = graph;
By reallocating the array of pointers to the AVFilterContexts before allocating the new AVFilterContext one can avoid freeing the new AVFilterContext in case the array could not be reallocated. Also switch to av_realloc_array() while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavfilter/avfiltergraph.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)