From 2cdda45c16f6c0f4093b2fbe841ea652cef90b4c Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Wed, 20 Sep 2017 14:42:19 +0200 Subject: [PATCH] Unconditionally close allocated stderr FDs --- src/ezstream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ezstream.c b/src/ezstream.c index c5c9273..e11d806 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -294,8 +294,7 @@ openResource(stream_t stream, const char *filename, int *popenFlag, } dup2(fd, fileno(stderr)); - if (fd > 2) - close(fd); + close(fd); } fflush(NULL); @@ -316,7 +315,7 @@ openResource(stream_t stream, const char *filename, int *popenFlag, if (cfg_get_program_quiet_stderr()) dup2(stderr_fd, fileno(stderr)); - if (stderr_fd > 2) + if (stderr_fd != -1) close(stderr_fd); return (filep);