Otherwise, a subsequent filter might refer to a buffer reference of
the previous filter, accessing freed memory. This is not a bug right
now, as audiod only closes filters after the full buffer tree has
become inactive, i.e. after all buffer tree nodes have unregistered
their task. It's cleaner to reverse the loop though, and it has no
additional cost.
struct audio_format_info *a = afi + s->format;
if (a->num_filters == 0)
return;
- for (i = 0; i < a->num_filters; i++) {
+ for (i = a->num_filters - 1; i >= 0; i--) {
struct filter_node *fn = s->fns + i;
struct filter *f;