mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-01-18 13:21:08 +00:00
avfilter/avfiltergraph: Simplify adding filter to 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>
This commit is contained in:
parent
68815d6791
commit
22c4f33991
@ -183,17 +183,15 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
|
||||
}
|
||||
}
|
||||
|
||||
filters = av_realloc_array(graph->filters, graph->nb_filters + 1, sizeof(*filters));
|
||||
if (!filters)
|
||||
return NULL;
|
||||
graph->filters = filters;
|
||||
|
||||
s = ff_filter_alloc(filter, name);
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
filters = av_realloc(graph->filters, sizeof(*filters) * (graph->nb_filters + 1));
|
||||
if (!filters) {
|
||||
avfilter_free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
graph->filters = filters;
|
||||
graph->filters[graph->nb_filters++] = s;
|
||||
|
||||
s->graph = graph;
|
||||
|
Loading…
Reference in New Issue
Block a user