aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorCyril Hrubis <chrubis@suse.cz>2015-05-20 13:50:00 +0200
committerAndreas Schwab <schwab@suse.de>2015-07-07 12:13:50 +0200
commitc13e07830800dd95ca7684b3c473394c77059c97 (patch)
tree6688377b329a6dc6167995e7ecf3b7202499f29a /misc
parent6471190491435c6ee819232f3eb71ad9638563cc (diff)
downloadglibc-c13e07830800dd95ca7684b3c473394c77059c97.zip
glibc-c13e07830800dd95ca7684b3c473394c77059c97.tar.gz
glibc-c13e07830800dd95ca7684b3c473394c77059c97.tar.bz2
Set errno to ENOMEM on overflow in sbrk (bug 18592)
Diffstat (limited to 'misc')
-rw-r--r--misc/sbrk.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/misc/sbrk.c b/misc/sbrk.c
index 87b5472..89ab9c4 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;