From 4192b13768ca86104ab0e2359a919443fec0a15b Mon Sep 17 00:00:00 2001 From: anonymous Date: Thu, 19 Jan 2012 00:04:04 +0000 Subject: [PATCH] ls: allocate proper space for args --- ls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ls.c b/ls.c index e64d673..c76bf18 100644 --- a/ls.c +++ b/ls.c @@ -62,7 +62,7 @@ main(int argc, char *argv[]) many = (argc > optind+1); if((n = argc - optind) > 0) { - if(!(ents = malloc((argc-1) * sizeof *ents))) + if(!(ents = malloc(n * sizeof *ents))) eprintf("malloc:"); for(i = 0; i < n; i++) mkent(&ents[i], argv[optind+i]);