From 76a1cae5d8c9cf0279a5b7a5e5caeadfa0c76fd9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 8 Feb 2017 17:04:46 +0100 Subject: [PATCH] {input,mixer}/alsa: fix off-by-one bug in count check Doesn't make a practical difference - but it's more correct this way. --- src/input/plugins/AlsaInputPlugin.cxx | 2 +- src/mixer/plugins/AlsaMixerPlugin.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index 4b3fd38de..7c5e55e56 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -181,7 +181,7 @@ AlsaInputStream::PrepareSockets() } int count = snd_pcm_poll_descriptors_count(capture_handle); - if (count < 0) { + if (count <= 0) { ClearSocketList(); return std::chrono::steady_clock::duration(-1); } diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 255439932..4f0e329a8 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -102,7 +102,7 @@ AlsaMixerMonitor::PrepareSockets() } int count = snd_mixer_poll_descriptors_count(mixer); - if (count < 0) + if (count <= 0) count = 0; struct pollfd *pfds = pfd_buffer.Get(count);