[hackers] [sbase] ls: allocate proper space for args || anonymous
changeset: 99:cf054f63a5c5
tag: tip
user: anonymous <p37sitdu_AT_lavabit.com>
date: Thu Jan 19 00:04:04 2012 +0000
files: ls.c
description:
ls: allocate proper space for args
diff -r dcb29ce4485f -r cf054f63a5c5 ls.c
--- a/ls.c Tue Nov 08 19:35:38 2011 +0100
+++ b/ls.c Thu Jan 19 00:04:04 2012 +0000
_AT_@ -62,7 +62,7 @@
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]);
Received on Mon Jan 23 2012 - 22:53:46 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 23 2012 - 23:00:14 CET