diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-06-25 14:07:19 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-06-25 14:07:19 -0400 |
commit | 8ea91a14b24714517e8aafcd59fd774ed7354ecb (patch) | |
tree | 5eaa574ec54a502e40bba4f9c086870f4ed01598 /exec.c | |
parent | fcd95bfc4801037d747328911d2201a81cca5534 (diff) | |
download | bfs-8ea91a14b24714517e8aafcd59fd774ed7354ecb.tar.xz |
exec: Don't assume bfs_exec_debug() doesn't change errno
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -446,13 +446,14 @@ static bool bfs_exec_args_remain(const struct bfs_exec *execbuf) { /** Execute the pending command from a BFS_EXEC_MULTI execbuf. */ static int bfs_exec_flush(struct bfs_exec *execbuf) { - int ret = 0; + int ret = 0, error = 0; size_t orig_argc = execbuf->argc; while (bfs_exec_args_remain(execbuf)) { execbuf->argv[execbuf->argc] = NULL; ret = bfs_exec_spawn(execbuf); - if (ret == 0 || errno != E2BIG) { + error = errno; + if (ret == 0 || error != E2BIG) { break; } @@ -466,8 +467,6 @@ static int bfs_exec_flush(struct bfs_exec *execbuf) { size_t new_argc = execbuf->argc; size_t new_size = execbuf->arg_size; - int error = errno; - for (size_t i = execbuf->tmpl_argc - 1; i < new_argc; ++i) { free(execbuf->argv[i]); } |