From 08997ab1211eb3ee52feeb7bd9062da2f168f834 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 19 Oct 2016 00:22:07 +0000 Subject: bugfix: child_spawn() error path now closes the right amount of fds --- src/libstddjb/child_spawn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index addc7cd..2170a6e 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -53,7 +53,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const unsigned int i = 0 ; char modifs[m + 1 + n * UINT_FMT] ; byte_copy(modifs, sizeof(NOFDVAR), NOFDVAR "=") ; - for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errp ; } + for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errpi ; } for (i = 0 ; i < n ; i++) if ((ndelay_on(p[i][i & 1]) < 0) || (coe(p[i][i & 1]) < 0)) { @@ -184,6 +184,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const #endif errp: i = n ; + errpi: while (i--) { fd_close(p[i][1]) ; -- cgit v1.2.3