Make avfilter_graph_parse() only release the internal structures allocated during the parsing, and leave to free the graph itself to the calling code. This approach looks cleaner, as the graph is not allocated by the function.
Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all
Unified · Split
| @@ -393,7 +393,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 392 unmodified lines | ||
| 393 | 393 | return 0; |
| 394 | 394 | |
| 395 | 395 | fail: |
| 396 | − avfilter_graph_free(graph); | |
| 396 | + for (; graph->filter_count > 0; graph->filter_count--) | |
| 397 | + avfilter_free(graph->filters[graph->filter_count - 1]); | |
| 398 | + av_freep(&graph->filters); | |
| 397 | 399 | free_inout(open_inputs); |
| 398 | 400 | free_inout(open_outputs); |
| 399 | 401 | free_inout(curr_inputs); |