From 1aef9e5556484d0a2d44370b88121310a8081725 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 19 Jan 2015 21:17:20 +0100 Subject: [PATCH] gui.c Fix error handling of for_each_stat_item(). 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gui.c b/gui.c index 552b625b..370c731c 100644 --- 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(); -- 2.39.5