]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gui.c Fix error handling of for_each_stat_item().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 19 Jan 2015 20:17:20 +0000 (21:17 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 20 Jan 2015 08:37:41 +0000 (09:37 +0100)
In status_post_select(), if read_nonblock() succeeds (ret >= 0)
but for_each_stat_item() fails (ret2 < 0), para_gui aborts with

para_gui: error.h:639: para_strerror: Assertion `num > 0' failed.

This happens for example if the user is not allowed to connect to
para_audiod.

The problem is that the (non-positive) value -ret is passed to
para_strerror() as the error code rather than -ret2. This commit
fixes the bug. It was introduced one year ago in commit f840be8d
(gui: Introduce status_post_select()).

gui.c

diff --git a/gui.c b/gui.c
index 552b625bb9749b40538bcf229d813125f09bd500..370c731cb916ac00749ad6ccdfbdd8138d2c41cb 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -659,7 +659,8 @@ static int status_post_select(struct sched *s, void *context)
        ret2 = for_each_stat_item(st->buf, st->loaded, update_item);
        if (ret < 0 || ret2 < 0) {
                st->loaded = 0;
-               PARA_NOTICE_LOG("closing stat pipe: %s\n", para_strerror(-ret));
+               PARA_NOTICE_LOG("closing stat pipe: %s\n",
+                       para_strerror(ret < 0? -ret : -ret2));
                close(st->fd);
                st->fd = -1;
                clear_all_items();