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