[llvm-commits] CVS: llvm/tools/llvm-ar/llvm-ar.cpp
Chris Lattner
clattner at apple.com
Sun Apr 8 12:29:42 PDT 2007
On Apr 7, 2007, at 11:53 AM, Reid Spencer wrote:
>
> @@ -281,7 +281,8 @@
> for (std::set<sys::Path>::iterator I = content.begin(), E =
> content.end();
> I != E; ++I) {
> // Make sure it exists and is a directory
> - const sys::FileStatus *Status = I->getFileStatus(false,
> ErrMsg);
> + const sys::FileStatus *Status =
> + sys::PathWithStatus(*I).getFileStatus(false, ErrMsg);
This series of changes is not safe. "Status" points to an ivar of a
temporary that is destroyed at the end of the statement. You want
something like:
sys::PathWithStatus Tmp(*I);
const sys::FileStatus *Status = Tmp.getFileStatus(false, ErrMsg);
This bug also occurs in llvm-db/Commands.cpp, llvmc/
CompilerDriver.cpp, and Debugger/ProgramInfo.cpp.
-Chris
> if (!Status)
> return true;
> if (Status->isDir) {
> @@ -309,7 +310,8 @@
> if (!aPath.exists())
> throw std::string("File does not exist: ") + Members[i];
> std::string Err;
> - const sys::FileStatus *si = aPath.getFileStatus(false, &Err);
> + const sys::FileStatus *si =
> + sys::PathWithStatus(aPath).getFileStatus(false, &Err);
> if (!si)
> throw Err;
> if (si->isDir) {
> @@ -645,7 +647,8 @@
>
> if (found != remaining.end()) {
> std::string Err;
> - const sys::FileStatus *si = found->getFileStatus(false, &Err);
> + const sys::FileStatus *si =
> + sys::PathWithStatus(*found).getFileStatus(false, &Err);
> if (!si)
> return true;
> if (si->isDir) {
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list