mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-21 12:00:06 +00:00
Add check for unexpected EOF to LoadDDSTextureFromFile
This commit is contained in:
parent
bc1aecbcf8
commit
b736e9edc3
@ -1944,11 +1944,18 @@ HRESULT DirectX::LoadFromDDSFile(
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
if (!ReadFile(hFile.get(), image.GetPixels(), static_cast<DWORD>(image.GetPixelsSize()), &bytesRead, nullptr))
|
||||
auto pixelBytes = static_cast<DWORD>(image.GetPixelsSize());
|
||||
if (!ReadFile(hFile.get(), image.GetPixels(), pixelBytes, &bytesRead, nullptr))
|
||||
{
|
||||
image.Release();
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
if (bytesRead != pixelBytes)
|
||||
{
|
||||
image.Release();
|
||||
return E_FAIL;
|
||||
}
|
||||
#else
|
||||
inFile.read(reinterpret_cast<char*>(image.GetPixels()), image.GetPixelsSize());
|
||||
if (!inFile)
|
||||
|
Loading…
Reference in New Issue
Block a user