[PATCH] builtin-add: fix command line building to call interactive

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] builtin-add: fix command line building to call interactive

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:53

The earlier 7c0ab4458994aa895855abc4a504cf693ecc0cf1 (Teach builtin-add
to pass multiple paths to git-add--interactive) did not allocate enough,
and had unneeded (void*) pointer arithmetic.

Signed-off-by: Junio C Hamano <redacted>
---

 builtin-add.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index dd895df..7c6a296 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -138,9 +138,10 @@ static void refresh(int verbose, const char **pathspec)
 int interactive_add(int argc, const char **argv)
 {
 	int status;
-	const char **args = xmalloc(sizeof(const char *) * (argc + 1));
+	const char **args = xcalloc(sizeof(const char *), (argc + 2));
+
 	args[0] = "add--interactive";
-	memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);
+	memcpy(&(args[1]), argv, sizeof(const char *) * argc);
 	args[argc + 1] = NULL;
 
 	status = run_command_v_opt(args, RUN_GIT_CMD);
-- 
1.5.3.6.2014.g7500f

Re: [PATCH] builtin-add: fix command line building to call interactive

From: Wincent Colaiuta <hidden>
Date: 2016-06-15 22:43:53

El 25/11/2007, a las 19:07, Junio C Hamano escribió:
The earlier 7c0ab4458994aa895855abc4a504cf693ecc0cf1 (Teach builtin- 
add
to pass multiple paths to git-add--interactive) did not allocate  
enough,
Yes, it was off by one; sorry about that. You may have noticed that I  
fixed that up in the patches I sent out yesterday and today. May need  
to redo them now to apply on top of this.

Cheers,
Wincent
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help