mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
[SF 2835206] File_WIN32 not checking against INVALID_HANDLE_VALUE
This commit is contained in:
@@ -48,13 +48,16 @@ class FileHandle
|
|||||||
public:
|
public:
|
||||||
FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
|
FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
|
||||||
{
|
{
|
||||||
_h = CreateFileA(path.c_str(), access, share, 0, disp, 0, 0);
|
_h = CreateFileA(upath.c_str(), access, share, 0, disp, 0, 0);
|
||||||
if (!_h) FileImpl::handleLastErrorImpl(path);
|
if (_h == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
FileImpl::handleLastErrorImpl(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileHandle()
|
~FileHandle()
|
||||||
{
|
{
|
||||||
if (_h) CloseHandle(_h);
|
if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE get() const
|
HANDLE get() const
|
||||||
|
|||||||
@@ -50,12 +50,15 @@ public:
|
|||||||
FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
|
FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
|
||||||
{
|
{
|
||||||
_h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
|
_h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
|
||||||
if (!_h) FileImpl::handleLastErrorImpl(path);
|
if (_h == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
FileImpl::handleLastErrorImpl(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileHandle()
|
~FileHandle()
|
||||||
{
|
{
|
||||||
if (_h) CloseHandle(_h);
|
if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE get() const
|
HANDLE get() const
|
||||||
|
|||||||
Reference in New Issue
Block a user