X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fmv.c;h=5efe6c5760c43d0059a940ab9d4610b97092c8bd;hb=afb6b561e3dad13df5d9df9731751a3d310c0854;hp=40f33ca4d0e6d0bb1733e0544029c6f588d09b59;hpb=8ab19bc5de68c8929317f8aa694709b9e4b72956;p=git.git diff --git a/builtin/mv.c b/builtin/mv.c index 40f33ca4d..5efe6c576 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -29,7 +29,11 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec, to_copy--; if (to_copy != length || base_name) { char *it = xmemdupz(result[i], to_copy); - result[i] = base_name ? strdup(basename(it)) : it; + if (base_name) { + result[i] = xstrdup(basename(it)); + free(it); + } else + result[i] = it; } } return get_pathspec(prefix, result);