From: Pino Toscano Date: Fri, 25 Jul 2014 15:36:17 +0000 (+0200) Subject: p2v: close the mexp handle if mexp_spawnv fails X-Git-Tag: v1.1~16 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=d911800d008faef4d35b6a55adcc2d5f8064cfc1;p=miniexpect.git p2v: close the mexp handle if mexp_spawnv fails --- diff --git a/miniexpect.c b/miniexpect.c index 9e9cc0e..8c1efd9 100644 --- a/miniexpect.c +++ b/miniexpect.c @@ -121,7 +121,7 @@ mexp_spawnl (const char *file, const char *arg, ...) mexp_h * mexp_spawnv (const char *file, char **argv) { - mexp_h *h; + mexp_h *h = NULL; int fd = -1; int err; char slave[1024]; @@ -197,6 +197,8 @@ mexp_spawnv (const char *file, char **argv) close (fd); if (pid > 0) waitpid (pid, NULL, 0); + if (h != NULL) + mexp_close (h); errno = err; return NULL; }