diff options
author | Jim Meyering <jim@meyering.net> | 2000-01-24 13:48:12 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-01-24 13:48:12 +0000 |
commit | efa9563f3d0b78f1fe29654c9b197c3bd6412d97 (patch) | |
tree | e50c925701fbb1bd6e652bc9b674bea4924cf1fa | |
parent | ae5c430364c1b71a5d7082597bacfcc66aba1743 (diff) | |
download | coreutils-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.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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)); |