Re: PATCH] bisect--helper: plug strvec leak in bisect_start()
René Scharfe <l.s.r@web.de> writes:
Show 5 quoted lines
> The strvec "argv" is used to build a command for run_command_v_opt(),
> but never freed. Use the "args" strvec of struct child_process and
> run_command() instead, which releases the allocated memory both on
> success and on error. We just also need to set the "git_cmd" bit
> directly.
Well reasoned and explained.
Thanks.
Show 28 quoted lines
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> builtin/bisect--helper.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 501245fac9..9fe0c08479 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -765,11 +765,12 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, const char **a
> strbuf_read_file(&start_head, git_path_bisect_start(), 0);
> strbuf_trim(&start_head);
> if (!no_checkout) {
> - struct strvec argv = STRVEC_INIT;
> + struct child_process cmd = CHILD_PROCESS_INIT;
>
> - strvec_pushl(&argv, "checkout", start_head.buf,
> + cmd.git_cmd = 1;
> + strvec_pushl(&cmd.args, "checkout", start_head.buf,
> "--", NULL);
> - if (run_command_v_opt(argv.v, RUN_GIT_CMD)) {
> + if (run_command(&cmd)) {
> res = error(_("checking out '%s' failed."
> " Try 'git bisect start "
> "<valid-branch>'."),
> --
> 2.37.3