summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-02-28 22:21:18 +0100
committerVicent Marti <tanoku@gmail.com>2011-03-03 20:23:51 +0200
commit669db21b288dc06781a35c4516aa19bac84800f6 (patch)
treec1c1ca58d3265e4d53976e049ecf039aaa088b23 /src/util.c
parent52b2c2092a4b12e4550a6850a9013264a7297af0 (diff)
downloadlibgit2-669db21b288dc06781a35c4516aa19bac84800f6.tar.gz
Slightly changed the behavior of git__joinpath() and git__joinpath_n().
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index fc1682f90..2f1bd2220 100644
--- a/src/util.c
+++ b/src/util.c
@@ -206,6 +206,7 @@ void git__joinpath_n(char *buffer_out, int count, ...)
{
va_list ap;
int i;
+ char *buffer_start = buffer_out;
va_start(ap, count);
for (i = 0; i < count; ++i) {
@@ -213,9 +214,12 @@ void git__joinpath_n(char *buffer_out, int count, ...)
int len;
path = va_arg(ap, const char *);
- if (i > 0 && *path == '/')
+ if (i > 0 && *path == '/' && buffer_out > buffer_start && buffer_out[-1] == '/')
path++;
+ if (!*path)
+ continue;
+
len = strlen(path);
memcpy(buffer_out, path, len);
buffer_out = buffer_out + len;