summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2010-03-30 17:36:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-30 21:46:33 (GMT)
commitda1fbed3fff6ed2d64399ff26d8a9ab3bcf00540 (patch)
treeb810119d3ab515951778b908c1c5ff2c5d47592a /diff.c
parent657ab61efa918f46f1b412613643d1a1bbed2194 (diff)
downloadgit-da1fbed3fff6ed2d64399ff26d8a9ab3bcf00540.zip
git-da1fbed3fff6ed2d64399ff26d8a9ab3bcf00540.tar.gz
git-da1fbed3fff6ed2d64399ff26d8a9ab3bcf00540.tar.bz2
diff: fix textconv error zombies
To make the code simpler, run_textconv lumps all of its error checking into one conditional. However, the short-circuit means that an error in reading will prevent us from calling finish_command, leaving a zombie child. Clean up properly after errors. Based-on-work-by: Jeff King <peff@peff.net> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 0d465fa..9905923 100644
--- a/diff.c
+++ b/diff.c
@@ -3865,6 +3865,7 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
const char **arg = argv;
struct child_process child;
struct strbuf buf = STRBUF_INIT;
+ int err = 0;
temp = prepare_temp_file(spec->path, spec);
*arg++ = pgm;
@@ -3875,16 +3876,20 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
child.use_shell = 1;
child.argv = argv;
child.out = -1;
- if (start_command(&child) != 0 ||
- strbuf_read(&buf, child.out, 0) < 0 ||
- finish_command(&child) != 0) {
- close(child.out);
- strbuf_release(&buf);
+ if (start_command(&child)) {
remove_tempfile();
- error("error running textconv command '%s'", pgm);
return NULL;
}
+
+ if (strbuf_read(&buf, child.out, 0) < 0)
+ err = error("error reading from textconv command '%s'", pgm);
close(child.out);
+
+ if (finish_command(&child) || err) {
+ strbuf_release(&buf);
+ remove_tempfile();
+ return NULL;
+ }
remove_tempfile();
return strbuf_detach(&buf, outsize);