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.
This commit is contained in:
parent
e06b1fa05e
commit
25e159c930
|
@ -76,20 +76,11 @@ int brk(void *addr)
|
||||||
|
|
||||||
void *sbrk(int incr)
|
void *sbrk(int incr)
|
||||||
{
|
{
|
||||||
char *base, *nbreak;
|
char *base;
|
||||||
|
|
||||||
brk_init();
|
brk_init();
|
||||||
base = cbreak;
|
base = cbreak;
|
||||||
nbreak = base + incr;
|
if (brk1(base + incr) < 0)
|
||||||
|
|
||||||
/* Did base + incr overflow? */
|
|
||||||
if ((incr < 0 && nbreak > base) ||
|
|
||||||
(incr > 0 && nbreak < base)) {
|
|
||||||
errno = ENOMEM;
|
|
||||||
return (void*)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (brk1(nbreak) < 0)
|
|
||||||
return (void*)-1;
|
return (void*)-1;
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue