# [PATCH] argv created by handle_alias should be NULL terminated

1 messages from 2006-07-14 to 2006-07-14. Participants: Matthias Lederhofer.
Thread: https://gitlist.dev/t/4887

## Matthias Lederhofer, 2006-07-14 16:37

Subject: [PATCH] argv created by handle_alias should be NULL terminated
Message-ID: <E1G1Qf4-0007Ji-MH@moooo.ath.cx>
URL: https://gitlist.dev/e/E1G1Qf4-0007Ji-MH%40moooo.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

```
