← Commit list

7b4e89b9e

Glenn L McGrath
Glenn L McGrath
2002-12-10
SOURCE BUG Duration: 5s

Subject

Fix undefined behaviour and save some bytes as suggested by Manuel Novoa III

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): sysdeps/linux/Config.in "fileutils/Config.in" dosyasini kaynak gosteriyor ama bu dosya repoda hic var olmadi (2002-12-05 - 2003-02-15 arasi orijinal yazar hatasi, 3238ea167 ile duzeltildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

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/realpath.c+10 -12
@@ -21,24 +21,22 @@
int realpath_main(int argc, char **argv)
{
- char *resolved_path;
- int count;
+ RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
- if (argc == 1) {
+ if (--argc == 0) {
show_usage();
}
- resolved_path = malloc(PATH_MAX);
-
- for (count = 1; count < argc; count++) {
- resolved_path = realpath(argv[count], resolved_path);
- if (resolved_path) {
+ do {
+ argv++;
+ if (realpath(*argv, resolved_path) != NULL) {
puts(resolved_path);
} else {
- perror_msg("%s", argv[count]);
+ perror_msg("%s", *argv);
}
- }
- free(resolved_path);
+ } while (--argc);
+
+ RELEASE_CONFIG_BUFFER(resolved_path);
return(EXIT_SUCCESS);
-}
+}