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
Unified · Split
| @@ -36,13 +36,13 @@ void avfilter_graph_destroy(AVFilterGraph *graph) · 35 unmodified lines | |||
| 36 | 36 | ||
| 37 | int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) | 37 | int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) |
| 38 | { | 38 | { |
| 39 | graph->filters = av_realloc(graph->filters, | 39 | AVFilterContext **filters = av_realloc(graph->filters, |
| 40 | sizeof(AVFilterContext*) * ++graph->filter_count); | 40 | sizeof(AVFilterContext*) * (graph->filter_count+1)); |
| 41 | 41 | if (!filters) | |
| 42 | if (!graph->filters) | ||
| 43 | return AVERROR(ENOMEM); | 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 | return 0; | 47 | return 0; |
| 48 | } | 48 | } |