diff options
author | Emil Renner Berthing <esmil@mailme.dk> | 2013-05-24 17:42:23 +0200 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2013-06-08 19:11:53 +0200 |
commit | 8bdc1c7631969c322bf0187ce94dbd1a2d8a2a9f (patch) | |
tree | 722c042acf47ad1a55567028ae2bef1f566c58d4 | |
parent | 118ed4f30e89c9fb0e790c5384f0357d6985a152 (diff) | |
download | lem-8bdc1c7631969c322bf0187ce94dbd1a2d8a2a9f.tar.gz lem-8bdc1c7631969c322bf0187ce94dbd1a2d8a2a9f.tar.xz lem-8bdc1c7631969c322bf0187ce94dbd1a2d8a2a9f.zip |
io: fix memory leak on error in io.popen()
-rw-r--r-- | lem/io/core.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lem/io/core.c b/lem/io/core.c index d41c3d0..27ece00 100644 --- a/lem/io/core.c +++ b/lem/io/core.c @@ -269,11 +269,11 @@ io_popen(lua_State *T) int fd[2]; int err; - posix_spawn_file_actions_init(&fa); switch (mode) { case 0: /* "r" */ if (pipe(fd)) return io_strerror(T, errno); + posix_spawn_file_actions_init(&fa); posix_spawn_file_actions_adddup2(&fa, fd[1], 1); posix_spawn_file_actions_addclose(&fa, fd[1]); break; @@ -283,12 +283,14 @@ io_popen(lua_State *T) err = fd[0]; fd[0] = fd[1]; fd[1] = err; + posix_spawn_file_actions_init(&fa); posix_spawn_file_actions_adddup2(&fa, fd[1], 0); posix_spawn_file_actions_addclose(&fa, fd[1]); break; case 2: /* "rw" */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) return io_strerror(T, errno); + posix_spawn_file_actions_init(&fa); posix_spawn_file_actions_adddup2(&fa, fd[1], 0); posix_spawn_file_actions_adddup2(&fa, fd[1], 1); posix_spawn_file_actions_addclose(&fa, fd[1]); |