Make sure NULL is returned if we ran out of memory.