diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | misc/sbrk.c | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 0f5d45e55b..15deac774f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-07-07 Cyril Hrubis <chrubis@suse.cz> + + [BZ #18592] + * misc/sbrk.c: Set errno to ENOMEM on overflow. + 2015-07-06 Wilco Dijkstra <wdijkstr@arm.com> * sysdeps/aarch64/fpu/math_private.h (__ieee754_sqrt): diff --git a/misc/sbrk.c b/misc/sbrk.c index 87b5472bda..89ab9c4a8c 100644 --- a/misc/sbrk.c +++ b/misc/sbrk.c @@ -47,10 +47,15 @@ __sbrk (intptr_t increment) return __curbrk; oldbrk = __curbrk; - if ((increment > 0 - ? ((uintptr_t) oldbrk + (uintptr_t) increment < (uintptr_t) oldbrk) - : ((uintptr_t) oldbrk < (uintptr_t) -increment)) - || __brk (oldbrk + increment) < 0) + if (increment > 0 + ? ((uintptr_t) oldbrk + (uintptr_t) increment < (uintptr_t) oldbrk) + : ((uintptr_t) oldbrk < (uintptr_t) -increment)) + { + __set_errno (ENOMEM); + return (void *) -1; + } + + if (__brk (oldbrk + increment) < 0) return (void *) -1; return oldbrk; |