zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: fc resource leak
@ 2008-11-12 10:31 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2008-11-12 10:31 UTC (permalink / raw)
  To: Zsh workers

CID 128. In this case, a temporary file is not being closed when an
error condition occurs. Even though the file is deleted, it is still open.

Doing ls -l /proc/$$/fd on Linux makes it easy to see the open deleted
files. Running fc with the current event number prints a message to warn
about "current history line would recurse endlessly, aborted". Coverity
doesn't notice it but the same problem applies to two further error
messages down in the fclist() function.

Oliver

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.217
diff -u -r1.217 builtin.c
--- Src/builtin.c	5 Nov 2008 13:02:09 -0000	1.217
+++ Src/builtin.c	12 Nov 2008 10:23:53 -0000
@@ -1480,6 +1480,7 @@
 		    unqueue_signals();
 		    zwarnnam("fc",
 		      "current history line would recurse endlessly, aborted");
+                    fclose(out);
 		    unlink(fil);
 		    return 1;
 		}
@@ -1619,6 +1620,8 @@
 	    zwarnnam("fc", "no such event: %s", buf);
 	} else
 	    zwarnnam("fc", "no events in that range");
+        if (f != stdout)
+	    fclose(f);
 	return 1;
     }
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-12 10:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-12 10:31 PATCH: fc resource leak Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).