diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-18 19:25:11 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-18 19:25:11 +0000 |
commit | 36e3cbfd3bc3dceeefa7a4be1bffcf5b949682e2 (patch) | |
tree | 52cea7dabe62fa62b687bf17597a2003db23b932 /llvm/lib/System/Unix/Path.cpp | |
parent | 9fb88200c449d631fb095a4e26d4297d4b960f36 (diff) | |
download | bcm5719-llvm-36e3cbfd3bc3dceeefa7a4be1bffcf5b949682e2.tar.gz bcm5719-llvm-36e3cbfd3bc3dceeefa7a4be1bffcf5b949682e2.zip |
Get rid of file descriptor leak in create_file.
llvm-svn: 16395
Diffstat (limited to 'llvm/lib/System/Unix/Path.cpp')
-rw-r--r-- | llvm/lib/System/Unix/Path.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/System/Unix/Path.cpp b/llvm/lib/System/Unix/Path.cpp index 182a0bbd8ca..c9333decbfd 100644 --- a/llvm/lib/System/Unix/Path.cpp +++ b/llvm/lib/System/Unix/Path.cpp @@ -377,8 +377,10 @@ Path::create_file() { if (!is_file()) return false; // Create the file - if (0 != creat(path.c_str(), S_IRUSR | S_IWUSR)) + int fd = ::creat(path.c_str(), S_IRUSR | S_IWUSR); + if (fd < 0) ThrowErrno(std::string(path.c_str()) + ": Can't create file"); + ::close(fd); return true; } |