Blob Blame History Raw
From 22ade9b8c150240a960ca683ee6d8f53ce8bc6ea Mon Sep 17 00:00:00 2001
From: Jaroslav Kysela <perex@perex.cz>
Date: Fri, 24 May 2019 11:09:43 +0200
Subject: [PATCH 16/25] pcm_file: call pclose() correctly for popen()
 (coverity)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 src/pcm/pcm_file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index 52cc10a9436a..99db3754fa32 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -227,7 +227,14 @@ static int snd_pcm_file_open_output_file(snd_pcm_file_t *file)
 					file->final_fname);
 			return -errno;
 		}
-		fd = fileno(pipe);
+		fd = dup(fileno(pipe));
+		err = -errno;
+		pclose(pipe);
+		if (fd < 0) {
+			SYSERR("unable to dup pipe file handle for command %s",
+					file->final_fname);
+			return err;
+		}
 	} else {
 		if (file->trunc)
 			fd = open(file->final_fname, O_WRONLY|O_CREAT|O_TRUNC,
-- 
2.16.4