[xiph-commits] r13296 - trunk/ezstream/src

moritz at svn.xiph.org moritz at svn.xiph.org
Tue Jul 24 06:04:01 PDT 2007


Author: moritz
Date: 2007-07-24 06:04:01 -0700 (Tue, 24 Jul 2007)
New Revision: 13296

Modified:
   trunk/ezstream/src/ezstream.c
Log:
Fix the dang file descriptor leak of < 0.4.1 for good; the old fix only
took care of it partially. Diagnosed with the help from someone, who wishes
to stay anonymous. Thanks!


Modified: trunk/ezstream/src/ezstream.c
===================================================================
--- trunk/ezstream/src/ezstream.c	2007-07-24 03:19:12 UTC (rev 13295)
+++ trunk/ezstream/src/ezstream.c	2007-07-24 13:04:01 UTC (rev 13296)
@@ -570,7 +570,7 @@
 
 	*popenFlag = 0;
 	if (pezConfig->reencode) {
-		int	stderr_fd = dup(fileno(stderr));
+		int	stderr_fd = -1;
 
 		pCommandString = buildCommandString(extension, fileName, mdata);
 		metadata_free(&mdata);
@@ -581,6 +581,7 @@
 		if (qFlag) {
 			int fd;
 
+			stderr_fd = dup(fileno(stderr));
 			if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) {
 				printf("%s: Cannot open %s for redirecting STDERR output: %s\n",
 				       __progname, _PATH_DEVNULL, strerror(errno));
@@ -610,12 +611,12 @@
 		}
 		xfree(pCommandString);
 
-		if (qFlag) {
+		if (qFlag)
 			dup2(stderr_fd, fileno(stderr));
-			if (stderr_fd > 2)
-				close(stderr_fd);
-		}
 
+		if (stderr_fd > 2)
+			close(stderr_fd);
+
 		return (filep);
 	}
 



More information about the commits mailing list