aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/cp.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index bba54809..a843b90a 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -410,11 +410,10 @@ void cp_main(void)
}
if (destdir) {
- char *s = FLAG(D) ? getdirname(src) : getbasename(src);
+ char *s = FLAG(D) ? dirname(src) : getbasename(src);
TT.destname = xmprintf("%s/%s", destname, s);
if (FLAG(D)) {
- free(s);
if (!(s = fileunderdir(TT.destname, destname))) {
error_msg("%s not under %s", TT.destname, destname);
continue;