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>
This commit is contained in:
Johannes Schindelin 2006-07-30 18:35:21 +02:00 committed by Junio C Hamano
parent a060b803b4
commit f59aac47f3

View File

@ -477,9 +477,9 @@ static char *unique_path(const char *path, const char *branch)
char *newpath = xmalloc(strlen(path) + 1 + strlen(branch) + 8 + 1);
int suffix = 0;
struct stat st;
char *p = newpath + strlen(newpath);
char *p = newpath + strlen(path);
strcpy(newpath, path);
strcat(newpath, "~");
*(p++) = '~';
strcpy(p, branch);
for (; *p; ++p)
if ('/' == *p)