From 46aed20b32ee192955d30d9e81031071448b59f9 Mon Sep 17 00:00:00 2001 From: Tomohiro IKEDA Date: Fri, 29 Sep 2023 20:50:31 +0900 Subject: [PATCH] pcm: Add error handler for `read` that `snd_pcm_share_thread` function calls --- src/pcm/pcm_share.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c index 0699fc87..8eac3497 100644 --- a/src/pcm/pcm_share.c +++ b/src/pcm/pcm_share.c @@ -414,7 +414,12 @@ static void *snd_pcm_share_thread(void *data) Pthread_mutex_lock(&slave->mutex); if (pfd[0].revents & POLLIN) { char buf[1]; - read(pfd[0].fd, buf, 1); + err = read(pfd[0].fd, buf, 1); + if (err < 0) { + SYSERR("can't read from a pipe"); + Pthread_mutex_unlock(&slave->mutex); + return NULL; + } } } else { slave->polling = 0;