Thread (1 message) 1 message, 1 author, 2022-10-05

Re: PATCH] bisect--helper: plug strvec leak in bisect_start()

From: Junio C Hamano <hidden>
Date: 2022-10-05 19:42:04

René Scharfe [off-list ref] writes:
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.
quoted hunk
Signed-off-by: René Scharfe <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help