]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Don't crash on blank moods.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 6 May 2021 18:29:06 +0000 (20:29 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 6 May 2021 18:29:06 +0000 (20:29 +0200)
We special-case empty mood definitions (because we can't map the
osl object anyway), but we don't check whether the mood definition
contains anything else than whitespace or comments.

Such blank mood definitions result in an empty abstract syntax tree
indicated by ->ast of the mood parser's context structure being
NULL. We happily dereference that pointer in mp_eval_row() and die
by the resulting SIGSEGV.

The fix is trivial: simply treat blank moods in the same way as the
dummy mood, i.e. regard each audio file as admissible.

mp.c

diff --git a/mp.c b/mp.c
index 56c16e31d7baf64fbf7c415b015b3de2967b6a38..416b4f92065ef79716e7f966c3102e995071a112 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -541,6 +541,8 @@ bool mp_eval_row(const struct osl_row *aft_row, struct mp_context *ctx)
 {
        if (!ctx) /* dummy mood */
                return true;
 {
        if (!ctx) /* dummy mood */
                return true;
+       if (!ctx->ast) /* empty mood */
+               return true;
        assert(aft_row);
        ctx->aft_row = aft_row;
        ctx->have_afsi = false;
        assert(aft_row);
        ctx->aft_row = aft_row;
        ctx->have_afsi = false;