Get rid of file descriptor leak in create_file.

llvm-svn: 16395
This commit is contained in:
Reid Spencer 2004-09-18 19:25:11 +00:00
parent 9fb88200c4
commit 36e3cbfd3b
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}