~sircmpwn/mrsh

b5318ce347952fe1c8baded436a01af9246f668e — Simon Ser 6 months ago a3bcb40
builtin/wait: fix use-after-free
1 files changed, 6 insertions(+), 3 deletions(-)

M builtin/wait.c
M builtin/wait.c => builtin/wait.c +6 -3
@@ 99,13 99,16 @@ int builtin_wait(struct mrsh_state *state, int argc, char *argv[]) {
		}
	}

	free(pids);
	int status;
	if (argc == 1) {
		return EXIT_SUCCESS;
		status = EXIT_SUCCESS;
	} else {
		return pids[npids - 1].status;
		status = pids[npids - 1].status;
	}

	free(pids);
	return status;

failure:
	free(pids);
	return EXIT_FAILURE;