<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Apr 26, 2013, at 5:34 PM, Sean Silva <<a href="mailto:silvas@purdue.edu">silvas@purdue.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><span style="font-family: arial, sans-serif; font-size: 13px;">- char cwd[MAXPATHLEN];</span><br style="font-family: arial, sans-serif; font-size: 13px;"><span style="font-family: arial, sans-serif; font-size: 13px;">- if (pwd && ::getcwd(cwd, MAXPATHLEN)) {</span><br style="font-family: arial, sans-serif; font-size: 13px;"><span style="font-family: arial, sans-serif; font-size: 13px;">+ const char *cwd = llvm::sys::Path::</span><span style="font-family: arial, sans-serif; font-size: 13px;">GetCurrentDirectory().c_str();</span><br style="font-family: arial, sans-serif; font-size: 13px;"><span style="font-family: arial, sans-serif; font-size: 13px;">+ if (pwd && cwd) {</span><br style="font-family: arial, sans-serif; font-size: 13px;"><div><span style="font-family: arial, sans-serif; font-size: 13px;"><br></span></div><div><font face="arial, sans-serif">I don't think this is safe. GetCurrentDirectory returns a Path by value (which lives until the end of the statement), and the c_str() points into that Path.</font></div><div><font face="arial, sans-serif"><br></font></div></div></div></blockquote><div><br></div><div>I believe you are correct, Sean. How does revision 180658 look?</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div><font face="arial, sans-serif">-- Sean Silva</font></div></div></div></blockquote></div><br></body></html>