From 28378cc9b0121596ba0047e10887e682677ce47d Mon Sep 17 00:00:00 2001 From: johan Date: Sun, 18 Aug 2002 18:21:18 +0000 Subject: Correctly handle empty path arguments, e.g., whereis -S -f biff. Approved by: joerg, sheldonh (mentor) --- usr.bin/whereis/whereis.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/usr.bin/whereis/whereis.c b/usr.bin/whereis/whereis.c index e78e089..58ca04a 100644 --- a/usr.bin/whereis/whereis.c +++ b/usr.bin/whereis/whereis.c @@ -114,20 +114,16 @@ scanopts(int argc, char **argv) dirlist = &sourcedirs; dolist: i = 0; + *dirlist = realloc(*dirlist, (i + 1) * sizeof(char *)); + (*dirlist)[i] = NULL; while (optind < argc && strcmp(argv[optind], "-f") != 0 && strcmp(argv[optind], "-B") != 0 && strcmp(argv[optind], "-M") != 0 && strcmp(argv[optind], "-S") != 0) { - *dirlist = realloc(*dirlist, - (i + 2) * sizeof(char *)); - if (*dirlist == NULL) - abort(); - (*dirlist)[i] = argv[optind]; - i++; + decolonify(argv[optind], dirlist, &i); optind++; } - (*dirlist)[i] = NULL; break; case 'b': -- cgit v1.1