diff options
-rw-r--r-- | findutils/which.c | 4 | ||||
-rw-r--r-- | which.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/findutils/which.c b/findutils/which.c index 1e5e9eed5..b2acd78de 100644 --- a/findutils/which.c +++ b/findutils/which.c | |||
@@ -54,8 +54,7 @@ extern int which_main(int argc, char **argv) | |||
54 | found = 0; | 54 | found = 0; |
55 | for (i = 0; i < count; i++) { | 55 | for (i = 0; i < count; i++) { |
56 | char *buf; | 56 | char *buf; |
57 | buf = concat_path_file(buf, path_n); | 57 | buf = concat_path_file(path_n, *argv); |
58 | buf = concat_path_file(buf, *argv); | ||
59 | if (stat (buf, &filestat) == 0 | 58 | if (stat (buf, &filestat) == 0 |
60 | && filestat.st_mode & S_IXUSR) | 59 | && filestat.st_mode & S_IXUSR) |
61 | { | 60 | { |
@@ -63,6 +62,7 @@ extern int which_main(int argc, char **argv) | |||
63 | found = 1; | 62 | found = 1; |
64 | break; | 63 | break; |
65 | } | 64 | } |
65 | free(buf); | ||
66 | path_n += (strlen(path_n) + 1); | 66 | path_n += (strlen(path_n) + 1); |
67 | } | 67 | } |
68 | if (!found) | 68 | if (!found) |
@@ -54,8 +54,7 @@ extern int which_main(int argc, char **argv) | |||
54 | found = 0; | 54 | found = 0; |
55 | for (i = 0; i < count; i++) { | 55 | for (i = 0; i < count; i++) { |
56 | char *buf; | 56 | char *buf; |
57 | buf = concat_path_file(buf, path_n); | 57 | buf = concat_path_file(path_n, *argv); |
58 | buf = concat_path_file(buf, *argv); | ||
59 | if (stat (buf, &filestat) == 0 | 58 | if (stat (buf, &filestat) == 0 |
60 | && filestat.st_mode & S_IXUSR) | 59 | && filestat.st_mode & S_IXUSR) |
61 | { | 60 | { |
@@ -63,6 +62,7 @@ extern int which_main(int argc, char **argv) | |||
63 | found = 1; | 62 | found = 1; |
64 | break; | 63 | break; |
65 | } | 64 | } |
65 | free(buf); | ||
66 | path_n += (strlen(path_n) + 1); | 66 | path_n += (strlen(path_n) + 1); |
67 | } | 67 | } |
68 | if (!found) | 68 | if (!found) |