summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-01-24 13:48:12 +0000
committerJim Meyering <jim@meyering.net>2000-01-24 13:48:12 +0000
commitefa9563f3d0b78f1fe29654c9b197c3bd6412d97 (patch)
treee50c925701fbb1bd6e652bc9b674bea4924cf1fa
parentae5c430364c1b71a5d7082597bacfcc66aba1743 (diff)
downloadcoreutils-efa9563f3d0b78f1fe29654c9b197c3bd6412d97.tar.xz
(main): Don't expect array index `n_files - 1' to evaluate
to `-1' for unsigned int n_files == 0. Doing so lead to a segfault on alpha. From Michael Stone.
-rw-r--r--src/mv.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/mv.c b/src/mv.c
index 3e1e6b96c..71b4de856 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -464,12 +464,8 @@ main (int argc, char **argv)
file = argv + optind;
target_directory_specified = (target_directory != NULL);
- if (target_directory == NULL)
- {
- /* Be careful below. When n_files is 0, this value will be
- argv[0], `--', or an option string. */
- target_directory = file[n_files - 1];
- }
+ if (target_directory == NULL && n_files != 0)
+ target_directory = file[n_files - 1];
dest_is_dir = (n_files > 0 && isdir (target_directory));