<div dir="ltr"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">-  char cwd[MAXPATHLEN];</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">-  if (pwd && ::getcwd(cwd, MAXPATHLEN)) {</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">
<span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">+  const char *cwd = llvm::sys::Path::</span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">GetCurrentDirectory().c_str();</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">
<span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">+  if (pwd && cwd) {</span><br style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div style><font color="#000000" 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 style><font color="#000000" face="arial, sans-serif"><br></font></div><div style><font color="#000000" face="arial, sans-serif">-- Sean Silva</font></div></div>