summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-05-10 02:32:43 -0400
committerRich Felker <dalias@aerifal.cx>2012-05-10 02:32:43 -0400
commit5761bcc3848e5956e06b9390ea40875cd4833caf (patch)
tree81ab303c37773350082df64be40c8011283fd955
parent96a709f0e738e37fc17fbf1ea9367e8b42c31e4e (diff)
downloadnoxcuse-5761bcc3848e5956e06b9390ea40875cd4833caf.tar.gz
fix bug that prevented buffer reuse in grep
-rw-r--r--src/grep.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/grep.c b/src/grep.c
index 9f367cc..c5ea6f0 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -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;