ls: allocate proper space for args

This commit is contained in:
anonymous 2012-01-19 00:04:04 +00:00
parent cb291cc394
commit 4192b13768

2
ls.c
View File

@ -62,7 +62,7 @@ main(int argc, char *argv[])
many = (argc > optind+1); many = (argc > optind+1);
if((n = argc - optind) > 0) { if((n = argc - optind) > 0) {
if(!(ents = malloc((argc-1) * sizeof *ents))) if(!(ents = malloc(n * sizeof *ents)))
eprintf("malloc:"); eprintf("malloc:");
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
mkent(&ents[i], argv[optind+i]); mkent(&ents[i], argv[optind+i]);