← Commit list

d5fddcd57

Denys Vlasenko
Denys Vlasenko
2009-10-08
FAILED Duration: 38s

Subject

cp: revert a recent buggy change, and add a comment why it's wrong

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/cp.c+3 -1
@@ -182,10 +182,12 @@ int cp_main(int argc, char **argv)
if (copy_file(*argv, dest, flags) < 0) {
status = EXIT_FAILURE;
}
- free((void*)dest);
if (*++argv == last) {
+ /* possibly leaking dest... */
break;
}
+ /* don't move up: dest may be == last and not malloced! */
+ free((void*)dest);
}
/* Exit. We are NOEXEC, not NOFORK. We do exit at the end of main() */