@matheusbsbs / matheus-bagliano / commits / f59aac47f3
Fork 0

merge-recur: fix thinko in unique_path()

This could result in a nasty infinite loop, or in bogus names (it used the strlen() of the newly allocated buffer instead of the original buffer). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Jul 30, 2006 at 18:35 UTC f59aac47f3839367d0da04019b0fc2bd61345225
1 file changed +2 -2
merge-recursive.c
+2 -2
@@ -477,9 +477,9 @@ static char *unique_path(const char *path, const char *branch)
477 char *newpath = xmalloc(strlen(path) + 1 + strlen(branch) + 8 + 1);
478 int suffix = 0;
479 struct stat st;
480 - char *p = newpath + strlen(newpath);
480 + char *p = newpath + strlen(path);
481 strcpy(newpath, path);
482 - strcat(newpath, "~");
482 + *(p++) = '~';
483 strcpy(p, branch);
484 for (; *p; ++p)
485 if ('/' == *p)