diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index c040a9cefa..d4ce97792d 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -428,13 +428,19 @@ void avfilter_destroy(AVFilterContext *filter) filter->filter->uninit(filter); for(i = 0; i < filter->input_count; i ++) { - if(filter->inputs[i]) + if(filter->inputs[i]) { filter->inputs[i]->src->outputs[filter->inputs[i]->srcpad] = NULL; + avfilter_formats_unref(&filter->inputs[i]->in_formats); + avfilter_formats_unref(&filter->inputs[i]->out_formats); + } av_freep(&filter->inputs[i]); } for(i = 0; i < filter->output_count; i ++) { - if(filter->outputs[i]) + if(filter->outputs[i]) { filter->outputs[i]->dst->inputs[filter->outputs[i]->dstpad] = NULL; + avfilter_formats_unref(&filter->outputs[i]->in_formats); + avfilter_formats_unref(&filter->outputs[i]->out_formats); + } av_freep(&filter->outputs[i]); }