diff options
author | nulltoken <emeric.fermas@gmail.com> | 2011-02-05 19:22:44 +0100 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2011-02-05 19:23:51 +0100 |
commit | a79e8e632a674934843612084cd654475c2c85b5 (patch) | |
tree | cb8e58dceed3f9dca1e29bf000ac1d26def6f0f1 /src | |
parent | ca0fb40a6f3ec2b1a254e0d5e5f307cbed541251 (diff) | |
download | libgit2-a79e8e632a674934843612084cd654475c2c85b5.tar.gz |
Fixed a small issue in git__join_path(). Added tests to exercise git__join_path().
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c index e1f709962..67b74eeba 100644 --- a/src/util.c +++ b/src/util.c @@ -207,6 +207,8 @@ char *git__joinpath(const char *path_a, const char *path_b) int len_a, len_b; char *path_new; + assert(path_a && path_b); + len_a = strlen(path_a); len_b = strlen(path_b); @@ -216,7 +218,7 @@ char *git__joinpath(const char *path_a, const char *path_b) strcpy(path_new, path_a); - if (path_new[len_a - 1] != '/') + if (len_a > 0 && len_b > 0 && path_new[len_a - 1] != '/') path_new[len_a++] = '/'; if (path_b[0] == '/') |