Or std::vector<T>::operator[] invokes undefined behaviour if the argument is invalid (out of band).
Or printf() invokes undefined behaviour if an argument is of the wrong type (for example "%s" with a corresponding int).
Or strcpy invokes undefined behaviour if you give it invalid pointers (or non-null terminated strings, etc).
So, yeah, many functions can invoke undefined behaviour when they are called with bad arguments, that doesn’t make them bad functions.