Arjun Shankar wrote: > + (sz) = request2size (req); \ > + if (((sz) < (req)) This does not work correctly if sz is signed, which is allowed by the current API: INTERNAL_SIZE_T is allowed to be signed, and sz might be INTERNAL_SIZE_T. Perhaps the best fix would be to remove INTERNAL_SIZE_T and replace it with size_t everywhere; there's no real reason for INTERNAL_SIZE_T. Alternatively, we could change the documentation for INTERNAL_SIZE_T to say that it must be an unsigned type; this would be a simpler patch. > + /* Check for overflow. */ > + if (nb > SIZE_MAX - alignment - MINSIZE) > + { > + __set_errno (ENOMEM); > + return 0; > + } This causes the code to do an unnecessary overflow check, as it already checked nb against a (wrong) upper bound earlier. How about something like the attached patch for the code, instead? (I haven't tested this at all.)