diff --git a/DirectXTex/DirectXTexDDS.cpp b/DirectXTex/DirectXTexDDS.cpp index b89a9e2..e62ccd7 100644 --- a/DirectXTex/DirectXTexDDS.cpp +++ b/DirectXTex/DirectXTexDDS.cpp @@ -1944,11 +1944,18 @@ HRESULT DirectX::LoadFromDDSFile( } #ifdef WIN32 - if (!ReadFile(hFile.get(), image.GetPixels(), static_cast(image.GetPixelsSize()), &bytesRead, nullptr)) + auto pixelBytes = static_cast(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(image.GetPixels()), image.GetPixelsSize()); if (!inFile)