diff --git a/builtin/mv.c b/builtin/mv.c
index 10154bb3160f3f7c4e424ee817cf2de99d55f18e..2a144b011caa8ecb70f55976bdec60cae89fad9e 100644 (file)
--- a/builtin/mv.c
+++ b/builtin/mv.c
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);