In case of reallocation failure the pointer to the original filter array was lost. The correct behavior seems to just keep the old array and count. Originally committed as revision 22905 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/avfiltergraph.c (1 of 1 file). Show all
Unified · Split
| @@ -36,13 +36,13 @@ void avfilter_graph_destroy(AVFilterGraph *graph) · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) |
| 38 | 38 | { |
| 39 | − graph->filters = av_realloc(graph->filters, | |
| 40 | − sizeof(AVFilterContext*) * ++graph->filter_count); | |
| 41 | − | |
| 42 | − if (!graph->filters) | |
| 39 | + AVFilterContext **filters = av_realloc(graph->filters, | |
| 40 | + sizeof(AVFilterContext*) * (graph->filter_count+1)); | |
| 41 | + if (!filters) | |
| 43 | 42 | return AVERROR(ENOMEM); |
| 44 | 43 | |
| 45 | − graph->filters[graph->filter_count - 1] = filter; | |
| 44 | + graph->filters = filters; | |
| 45 | + graph->filters[graph->filter_count++] = filter; | |
| 46 | 46 | |
| 47 | 47 | return 0; |
| 48 | 48 | } |