ls: allocate proper space for args
This commit is contained in:
parent
cb291cc394
commit
4192b13768
2
ls.c
2
ls.c
@ -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]);
|
||||||
|
Loading…
Reference in New Issue
Block a user