Avoid use of a dangling pointer by using a copy of the std::string.  Pointed out
by Benjamin Kramer.