mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Get rid of file descriptor leak in create_file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16395 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -377,8 +377,10 @@ Path::create_file() {
|
|||||||
if (!is_file()) return false;
|
if (!is_file()) return false;
|
||||||
|
|
||||||
// Create the file
|
// 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");
|
ThrowErrno(std::string(path.c_str()) + ": Can't create file");
|
||||||
|
::close(fd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -377,8 +377,10 @@ Path::create_file() {
|
|||||||
if (!is_file()) return false;
|
if (!is_file()) return false;
|
||||||
|
|
||||||
// Create the file
|
// 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");
|
ThrowErrno(std::string(path.c_str()) + ": Can't create file");
|
||||||
|
::close(fd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user