skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 08997ab1211eb3ee52feeb7bd9062da2f168f834
parent 8be9590f78d0f7cf04ade6a2ff0bddd365e3fd7c
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Wed, 19 Oct 2016 00:22:07 +0000

 bugfix: child_spawn() error path now closes the right amount of fds

Diffstat:
Msrc/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 @@ -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]) ;