From: Ulrich Drepper Date: Thu, 8 Jul 1999 11:49:00 +0000 (+0000) Subject: (request2size): Also set errno if failing. X-Git-Tag: cvs/glibc_2-1-2~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a2cd2711f81210b8a53ae29eae5defc61dd46a4;p=thirdparty%2Fglibc.git (request2size): Also set errno if failing. (request2size): Take care of overflow in addition. --- diff --git a/malloc/malloc.c b/malloc/malloc.c index e096f00eebc..31ab045a065 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -314,6 +314,7 @@ extern "C" { #endif +#include #include /* needed for malloc_stats */ @@ -822,6 +823,10 @@ do { \ computed. */ +/* Macro to set errno. */ +#ifndef __set_errno +# define __set_errno(val) errno = (val) +#endif /* On some platforms we can compile internal, not exported functions better. Let the environment provide a macro and define it to be empty if it @@ -1263,8 +1268,10 @@ 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) \ + ? (__set_errno (ENOMEM), 1) \ + : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) \ + ? (nb = MINSIZE) : (nb &= ~MALLOC_ALIGN_MASK)), 0))) /* Check if m has acceptable alignment */