From 281caece46c4a82c8c4c49b0847867e3be053a85 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 27 May 2016 13:40:34 +0200 Subject: avfilter/avfiltergraph: Clear graph pointers in ff_filter_graph_remove_filter() When a filter is no longer part of a graph, its pointers should be cleared so no stale pointers remain. Signed-off-by: Michael Niedermayer --- libavfilter/avfiltergraph.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libavfilter') diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 9f50b4120d..42751132af 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -93,12 +93,17 @@ AVFilterGraph *avfilter_graph_alloc(void) void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter) { - int i; + int i, j; for (i = 0; i < graph->nb_filters; i++) { if (graph->filters[i] == filter) { FFSWAP(AVFilterContext*, graph->filters[i], graph->filters[graph->nb_filters - 1]); graph->nb_filters--; + filter->graph = NULL; + for (j = 0; jnb_outputs; j++) + if (filter->outputs[j]) + filter->outputs[j]->graph = NULL; + return; } } -- cgit v1.2.3