OSDN Git Service

avfilter/avfiltergraph: Clear graph pointers in ff_filter_graph_remove_filter()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 27 May 2016 11:40:34 +0000 (13:40 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 27 May 2016 14:30:25 +0000 (16:30 +0200)
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 <michael@niedermayer.cc>
libavfilter/avfiltergraph.c

index 9f50b41..4275113 100644 (file)
@@ -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; j<filter->nb_outputs; j++)
+                if (filter->outputs[j])
+                    filter->outputs[j]->graph = NULL;
+
             return;
         }
     }