Wouldn’t that cause undefined behavior?

For example, strf outputs a temporary pointer.