ISO/IEC 9899:TC2 (i.e. the C99 standard), §7.20.3 states:
If the size of the space requested is zero, the behavior is implementation-defined: either a null pointer is returned, or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object.
In other words, malloc(0) may either return NULL or a valid pointer which I may not dereference.
What is the rationale behind this behavior?
And wouldn't it be easier to just define that malloc(0) leads to UB?