threads / patch / 22060

patchtextconv: stop leaking file descriptors

Subject: [PATCH] textconv: stop leaking file descriptors

## tl;dr

One message between Dec 30, 2009 and Dec 30, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Jeff King· Dec 30, 2009, 09:02 UTC · lore

We read the output from textconv helpers over a pipe, but we never actually closed our end of the pipe after using it.

Signed-off-by: Jeff King <peff@peff.net>
---
This should go onto 'maint'. Now I'll just go find a brown paper bag...
 diff.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Show changes to diff.c +2 −0
diff --git a/diff.c b/diff.c
index d14a575..aad4b39 100644
--- a/diff.c
+++ b/diff.c
@@ -3823,11 +3823,13 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
 	if (start_command(&child) != 0 ||
 	    strbuf_read(&buf, child.out, 0) < 0 ||
 	    finish_command(&child) != 0) {
+		close(child.out);
 		strbuf_release(&buf);
 		remove_tempfile();
 		error("error running textconv command '%s'", pgm);
 		return NULL;
 	}
+	close(child.out);
 	remove_tempfile();
 
 	return strbuf_detach(&buf, outsize);
-- 
1.6.6.320.g7c9b3

← back to recent threads