Q: What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
A: The ANSI/ISO Standard says that it may do either; the behavior is implementation-defined (see question 11.33). Portable code must either take care not to call malloc(0), or be prepared for the possibility of a null return.
References:
ISO Sec. 7.10.3
PCS Sec. 16.1 p. 386