Branch: refs/heads/master
Home: https://github.com/xrootd/xrootd
Commit: 1e4d313b325ac2227643b8a5ece767bdf4711f2f
https://github.com/xrootd/xrootd/commit/1e4d313b325ac2227643b8a5ece767bdf4711f2f
Author: Mattias Ellert <[log in to unmask]>
Date: 2020-12-20 (Sun, 20 Dec 2020)
Changed paths:
M src/XrdCms/XrdCmsRedirLocal.cc
Log Message:
-----------
Don't save pointer to temporary
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.
Commit: 24b89dbf91dbf170a1f97fd21825c9f332dd1d6a
https://github.com/xrootd/xrootd/commit/24b89dbf91dbf170a1f97fd21825c9f332dd1d6a
Author: Andrew Hanushevsky <[log in to unmask]>
Date: 2020-12-21 (Mon, 21 Dec 2020)
Changed paths:
M src/XrdCms/XrdCmsRedirLocal.cc
Log Message:
-----------
Merge pull request #1368 from ellert/no-save-pointer-to-temporary
Don't save pointer to temporary
Compare: https://github.com/xrootd/xrootd/compare/0dcc70d8cd3f...24b89dbf91db
########################################################################
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
|