about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--malloc/malloc.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 0b5f773a78..37e91a4653 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 1999-07-07  Ulrich Drepper  <drepper@cygnus.com>
 
+	* malloc/malloc.c (request2size): Take care of overflow in
+	addition.
+
 	* sysdeps/posix/getcwd.c: Correct last patch.  Handle getcwd
 	(NULL, != 0) correctly.
 
diff --git a/malloc/malloc.c b/malloc/malloc.c
index e096f00eeb..09085e81ad 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1263,8 +1263,9 @@ static void      free_atfork();
 
 #define request2size(req, nb) \
  ((nb = (req) + (SIZE_SZ + MALLOC_ALIGN_MASK)),\
-  ((long)nb <= 0 ? 1 : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) ? (nb = MINSIZE) :\
-                         (nb &= ~MALLOC_ALIGN_MASK)), 0)))
+  ((long)nb <= 0 || nb < (INTERNAL_SIZE_T) (req) \
+   ? 1 : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) \
+	   ? (nb = MINSIZE) : (nb &= ~MALLOC_ALIGN_MASK)), 0)))
 
 /* Check if m has acceptable alignment */