audiod: Fix off-by-one bug in init_default_filters().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Jun 2017 20:09:01 +0000 (22:09 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 14 Jun 2017 17:53:58 +0000 (19:53 +0200)
Filter numbers are one-based because zero is the number of the
(non-existing) supercommand of the filter_cmd suite. The loop in
init_default_filters() gets this wrong.

This bites only if no filter is given for at least one audio format.
Fortunately, the bug was easy to find because it triggers an assertion
in filter_get() which checks that the given number is at least one.

audiod.c

index ead29e86b96dae01921ab4167f7231e308e7b76e..74d0ce233b46407c208022229df9a5da26e88f3b 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1001,7 +1001,7 @@ static int init_default_filters(void)
                }
                /* add "dec" to audio format name */
                tmp = make_message("%sdec", audio_formats[i]);
-               for (j = 0; filter_get(j); j++)
+               for (j = 1; filter_get(j); j++)
                        if (!strcmp(tmp, filter_name(j)))
                                break;
                free(tmp);