From: Johannes Schindelin Date: Sun, 30 Jul 2006 16:35:21 +0000 (+0200) Subject: merge-recur: fix thinko in unique_path() X-Git-Tag: v1.4.3-rc1~174^2~12 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f59aac47f3839367d0da04019b0fc2bd61345225;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/merge-recursive.c b/merge-recursive.c index 6a796f24c..5375a1ba3 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -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)