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 102735a..ee5a0e8 100644 (file)
--- a/git.c
+++ b/git.c
@@ -133,13 +133,12 @@ static int handle_alias(int *argcp, const char ***argv)
                                fflush(stderr);
                        }
 
                                fflush(stderr);
                        }
 
+                       new_argv = realloc(new_argv, sizeof(char*) *
+                                          (count + *argcp + 1));
                        /* insert after command name */
                        /* 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;
 
                        *argv = new_argv;
                        *argcp += count - 1;