git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] argv created by handle_alias should be NULL terminated

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Jul 14, 2006, 16:37 UTC
Message-ID
<E1G1Qf4-0007Ji-MH@moooo.ath.cx>
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Example:
% git repo-config alias.test am
% git test
error: cannot open mbox JÜ·JÜ·JÜ·JÜ· JÜ· JÜ·(JÜ·(JÜ [..]
---
 git.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/git.c b/git.c
index 102735a..ee5a0e8 100644
--- a/git.c
+++ b/git.c
@@ -133,13 +133,12 @@ static int handle_alias(int *argcp, cons
 				fflush(stderr);
 			}
 
+			new_argv = realloc(new_argv, sizeof(char*) *
+					   (count + *argcp + 1));
 			/* insert after command name */
-			if (*argcp > 1) {
-				new_argv = realloc(new_argv, sizeof(char*) *
-						   (count + *argcp));
-				memcpy(new_argv + count, *argv + 1,
-				       sizeof(char*) * *argcp);
-			}
+			memcpy(new_argv + count, *argv + 1,
+			       sizeof(char*) * *argcp);
+			new_argv[count+*argcp] = NULL;
 
 			*argv = new_argv;
 			*argcp += count - 1;
-- 
1.4.1.g8b4b
Message 1 of 1 in “argv created by handle_alias should be NULL terminated”
  1. argv created by handle_alias should be NULL terminatedMatthias Lederhofer, Jul 14, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.