From a6ceeec29fa8c721581c74ba3a41a3a97f9b1ce5 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 2 Dec 2021 14:07:01 +0100 Subject: [PATCH] tests/malloc: fix counting bug There is a corner cases in which the counting of allocated memory previously was wrong: When the allocation of the chunk succeeded but the allocation of the next struct node fails. This was relatively unlikely to happen, as the chunk size was much bigger than the memory required by the struct node. But it happens on the ESP32 boards resulting in failing nightlies. This fixes the issue. --- tests/malloc/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/malloc/main.c b/tests/malloc/main.c index 34fa1ccd11..e4ffac5e62 100644 --- a/tests/malloc/main.c +++ b/tests/malloc/main.c @@ -84,7 +84,7 @@ static void free_memory(struct node *head) while (head) { if (head->ptr) { - if (total > CHUNK_SIZE) { + if (total >= CHUNK_SIZE) { total -= CHUNK_SIZE; freed++; }