diff options
| author | nulltoken <emeric.fermas@gmail.com> | 2011-02-28 22:21:18 +0100 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-03 20:23:51 +0200 |
| commit | 669db21b288dc06781a35c4516aa19bac84800f6 (patch) | |
| tree | c1c1ca58d3265e4d53976e049ecf039aaa088b23 /src/util.c | |
| parent | 52b2c2092a4b12e4550a6850a9013264a7297af0 (diff) | |
| download | libgit2-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.c | 6 |
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; |
