From 25e159c930d2b95371be23dfe7365545338ec51a Mon Sep 17 00:00:00 2001 From: George Koehler Date: Sat, 3 Dec 2016 17:07:51 -0500 Subject: [PATCH] Remove bad overflow check from plat/osx/libsys/brk.c If I want to check for overflow, then I should check it before I do base + incr, not after. Now that I have no check, I am passing the overflowed base + incr to brk1(), where it will probably fail the nbreak < segment check. --- plat/osx/libsys/brk.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/plat/osx/libsys/brk.c b/plat/osx/libsys/brk.c index a732cac1c..9b58ca1d8 100644 --- a/plat/osx/libsys/brk.c +++ b/plat/osx/libsys/brk.c @@ -76,20 +76,11 @@ int brk(void *addr) void *sbrk(int incr) { - char *base, *nbreak; + char *base; brk_init(); base = cbreak; - nbreak = base + incr; - - /* Did base + incr overflow? */ - if ((incr < 0 && nbreak > base) || - (incr > 0 && nbreak < base)) { - errno = ENOMEM; - return (void*)-1; - } - - if (brk1(nbreak) < 0) + if (brk1(base + incr) < 0) return (void*)-1; return base; } -- 2.34.1