On Mon, 31 Dec 2012, Joerg Sonnenberger wrote:
Log Message: If malloc, calloc, or realloc returns NULL when a size of 0 was requested, which is allowed by pertinent standards, honor it instead of bombing. Do not do this for calloc(x, y) where x != 0 && y != 0 but x*y == 0; in that case bomb.The commit message is misleading. We expect calloc(x,y) to return NULL if x!=0 && y!=0 && x*y==0.
(x!=0 && y!=0 && x*y==0) can be true only if calculating x*y results in what would loosely be called integer overflow; since the types are unsigned, it's a well-defined kind of wraparound, not the undefined kind of overflow. I'd expect an error like EINVAL rather than an error like ENOMEM for this case. --apb (Alan Barrett)