The c_str() of a temporary std::string object is not valid after the lifetime of the object expires. Consider: ``` $ cat temp.cpp int main() { const char* c1 = std::string("ABC").c_str(); const char* c2 = std::string("DEF").c_str(); std::cout << c1 << std::endl; std::cout << c2 << std::endl; } $ g++ -O2 -o temp temp.cpp $ ./temp DEF DEF ``` The memory used by the first temporary std::string is reused by the second one, since the lifetime of the first has expired. So when the saved c_str() of the first string is written out, it writes the second string. You can view, comment on, or merge this pull request online at: https://github.com/xrootd/xrootd/pull/1368 -- Commit Summary -- * Don't save pointer to temporary -- File Changes -- M src/XrdCms/XrdCmsRedirLocal.cc (12) -- Patch Links -- https://github.com/xrootd/xrootd/pull/1368.patch https://github.com/xrootd/xrootd/pull/1368.diff -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/xrootd/xrootd/pull/1368 ######################################################################## Use REPLY-ALL to reply to list To unsubscribe from the XROOTD-DEV list, click the following link: https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1