From dd58a58692683ff7db568d3a15acd559bdad4934 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 15 Feb 2021 15:43:06 +1100 Subject: [PATCH] Put a lower bound on the amount of memory available during malloc testing and shrinking the window. --- stream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stream.c b/stream.c index 443f568..777855b 100644 --- a/stream.c +++ b/stream.c @@ -985,6 +985,14 @@ retest_malloc: testmalloc = malloc(testsize); if (!testmalloc) { limit = limit / 10 * 9; + if (limit < 100000000) { + /* If we can't even allocate 100MB then we'll never + * succeed */ + print_err("Unable to allocate enough memory for operation\n"); + dealloc(sinfo->s); + dealloc(sinfo); + return NULL; + } goto retest_malloc; } if (!NO_COMPRESS) {