diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2021-03-31 03:54:55 +0100 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2021-03-31 04:16:14 +0100 |
commit | d7a3aec8126abb4f9258aa41dcf6db550b315471 (patch) | |
tree | 5bda788703fd193fadf223a25f9a1f138c8290a1 | |
parent | 7b3aadd4999c4c150c7ac8ceed5586b75efc46a1 (diff) |
FileStream: Ensure file handle invalidation on error
If the file fails to open, the file handle must be invalidated.
Co-authored-by: Xadhoom <>
Co-authored-by: Anders Jenbo <anders@jenbo.dk>
-rw-r--r-- | src/FileStream.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/FileStream.cpp b/src/FileStream.cpp index a7b3e6a..45499e1 100644 --- a/src/FileStream.cpp +++ b/src/FileStream.cpp @@ -113,6 +113,7 @@ static bool BaseFile_Create(TFileStream * pStream) if(handle == -1)
{
nLastError = errno;
+ pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
return false;
}
@@ -165,6 +166,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD if(handle == -1)
{
nLastError = errno;
+ pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
return false;
}
@@ -173,6 +175,7 @@ static bool BaseFile_Open(TFileStream * pStream, const TCHAR * szFileName, DWORD {
nLastError = errno;
close(handle);
+ pStream->Base.File.hFile = INVALID_HANDLE_VALUE;
return false;
}
|