diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-05-10 02:32:43 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-05-10 02:32:43 -0400 |
commit | 5761bcc3848e5956e06b9390ea40875cd4833caf (patch) | |
tree | 81ab303c37773350082df64be40c8011283fd955 /src/grep.c | |
parent | 96a709f0e738e37fc17fbf1ea9367e8b42c31e4e (diff) | |
download | noxcuse-5761bcc3848e5956e06b9390ea40875cd4833caf.tar.gz |
fix bug that prevented buffer reuse in grep
Diffstat (limited to 'src/grep.c')
-rw-r--r-- | src/grep.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -71,7 +71,8 @@ int main(int argc, char **argv) static const char *optpat = "EFce:f:ilnqsvx"; FILE *f; char *line = 0; - ssize_t llen = 0; + size_t lsize = 0; + ssize_t llen; int b; int multifile; struct pattern *pat; @@ -139,7 +140,7 @@ int main(int argc, char **argv) process_stdin: count = 0; lineno = 0; - while ((llen = getline(&line, (size_t[]){0}, f)) >= 0) { + while ((llen = getline(&line, &lsize, f)) >= 0) { lineno++; if (llen && line[llen-1]=='\n') line[--llen] = 0; |