From 733bb3da0f1ef5005ffe5df7811875e737cb3414 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 7 Sep 2011 15:50:08 -0400 Subject: [PATCH] Add a safety check to nbfd of apps cmd pollfd Signed-off-by: David Goulet --- ltt-sessiond/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index c9522d697..436ee9f16 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -880,6 +880,15 @@ static int update_apps_cmd_pollfd(unsigned int nb_fd, unsigned int old_nb_fd, } } + if (nb_fd < 2) { + /* + * There should *always* be at least two fds in the pollfd. This safety + * check make sure the poll() will actually try on those two pipes at + * best which are the thread_quit_pipe and apps_cmd_pipe. + */ + nb_fd = 2; + } + /* Destroy old pollfd */ free(old_pollfd); -- 2.34.1