X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin%2Fmv.c;h=5efe6c5760c43d0059a940ab9d4610b97092c8bd;hb=992499d8532c107f0f77163de4376ed2e0fd05a0;hp=40f33ca4d0e6d0bb1733e0544029c6f588d09b59;hpb=d907bf8ef327cd47433d4a4bb0a1bb4e96b6e340;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);