From 3e85874b1ea00d395a2add6b1cf38eef34bc2c38 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Sun, 23 Nov 2008 17:54:33 +0100 Subject: [PATCH] Limit in-memory buffer size Limit the amount of saved data to 200Mb so we don't fail on large files. Original ticket: https://bugzilla.redhat.com/show_bug.cgi?id=198165 --- src/grep.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/grep.c b/src/grep.c index 4363b4a..46ce140 100644 --- a/src/grep.c +++ b/src/grep.c @@ -492,6 +492,12 @@ fillbuf (size_t save, struct stats const *stats) int cc = 1; char *readbuf; size_t readsize; + const size_t max_save = 200 * 1024 * 1024; + + /* Limit the amount of saved data to 200Mb so we don't fail on + * large files. */ + if (save > max_save) + save = max_save; /* Offset from start of buffer to start of old stuff that we want to save. */ -- 1.5.5.1