Code

argv created by handle_alias should be NULL terminated
authorMatthias Lederhofer <matled@gmx.net>
Fri, 14 Jul 2006 16:37:06 +0000 (18:37 +0200)
committerJunio C Hamano <junkio@cox.net>
Fri, 14 Jul 2006 18:32:39 +0000 (11:32 -0700)
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
git.c

diff --git a/git.c b/git.c
index 102735af6c0cfb496a04593ba466a9fbb18f693d..ee5a0e86a71119b5ac11c351a982e31c87649a15 100644 (file)
--- a/git.c
+++ b/git.c
@@ -133,13 +133,12 @@ static int handle_alias(int *argcp, const char ***argv)
                                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;