From: Jim Meyering Date: Fri, 9 May 2003 08:50:37 +0000 (+0000) Subject: (main): Don't overrun array bound if argc is 0. X-Git-Tag: v5.0.1~566 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=6476197bcb97237eda456791fca64edd1303680d;p=thirdparty%2Fcoreutils.git (main): Don't overrun array bound if argc is 0. That would happen when invoked via: execl ("/usr/bin/sort", NULL); --- diff --git a/src/sort.c b/src/sort.c index ede4960268..0357c8e337 100644 --- a/src/sort.c +++ b/src/sort.c @@ -2265,7 +2265,7 @@ main (int argc, char **argv) long_options, NULL)) == -1)) { - if (optind == argc) + if (argc < optind) break; files[nfiles++] = argv[optind++]; }