summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/builtin.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c19ad2f9..7d53aaa6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-18  Clint Adams  <clint@zsh.org>
+
+	* 25910: Src/builtin.c: avoid dangling file handle in bin_print.
+
 2008-10-17  Peter Stephenson  <pws@csr.com>
 
 	* Rocky: 25907: Test/Makefile.in: makefile needs .exe
diff --git a/Src/builtin.c b/Src/builtin.c
index e852092e2..003897bb4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3689,8 +3689,11 @@ bin_print(char *name, char **args, Options ops, int func)
     if (OPT_ISSET(ops,'o') || OPT_ISSET(ops,'O')) {
 	int flags;
 
-	if (fmt && !*args)
+	if (fmt && !*args) {
+	    if (fout != stdout)
+	        fclose(fout);
 	    return 0;
+	}
 	flags = OPT_ISSET(ops,'i') ? SORTIT_IGNORING_CASE : 0;
 	if (OPT_ISSET(ops,'O'))
 	    flags |= SORTIT_BACKWARDS;