This doesn't seem right. If src is not set you return a valid pointer to statically allocated character array and calling "free" on this later would cause undefined behaviour.