From ee6ae720c9c415079f7696bacba3704504eba801 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 28 Jun 2016 10:46:15 +0100 Subject: [PATCH] malloc: do the overflow maths in unsigned --- Library/libs/malloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/libs/malloc.c b/Library/libs/malloc.c index abe00a49..2e567fba 100644 --- a/Library/libs/malloc.c +++ b/Library/libs/malloc.c @@ -33,7 +33,7 @@ static struct memh *brkmore(size_t nb) if (p == (struct memh *) -1) return NULL; /* Overflow catch */ - if (p + nb < p) + if ((uintptr_t)p + sizeof(struct memh) * nb < (uintptr_t)p) return NULL; /* Move our break point. Using brk this way avoids the sign problems */ if (brk(p + nb)) -- 2.34.1