]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Avoid NULL pointer dereference in make_status_items().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 16 Jul 2017 14:21:07 +0000 (16:21 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 16 Jul 2017 14:33:54 +0000 (16:33 +0200)
The previous patch (Update status items on blob events) modified the
aft event handler to call make_status_items() on certain blob events
because the event could have rendered the current status information
stale.

However, if no audio file is open at the time the event occurs,
make_status_items() triggers a segfault because the ->path and ->hash
members of status_item_ls_data are NULL in this case.

This patch avoids the problem by returning early from
make_status_items() if ->path is NULL.

aft.c

diff --git a/aft.c b/aft.c
index 4ed703ec0df094e8f3dd6ca7668de77b8bc27c0b..36f84943acfbad59fcfea1b03312d3e073b3824e 100644 (file)
--- a/aft.c
+++ b/aft.c
@@ -983,6 +983,8 @@ static int make_status_items(void)
        time_t current_time;
        int ret;
 
+       if (!status_item_ls_data.path) /* no audio file open */
+               return 0;
        ret = lls_parse(ARRAY_SIZE(argv), argv, cmd, &opts.lpr, NULL);
        assert(ret >= 0);
        time(&current_time);