Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting for TGAs with invalid palettes #570

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion DirectXTex/DirectXTexTGA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ HRESULT DirectX::LoadFromTGAMemory(

const size_t remaining = size - offset - paletteOffset;
if (remaining == 0)
return E_FAIL;
return HRESULT_E_HANDLE_EOF;

const void* pPixels = static_cast<const uint8_t*>(pSource) + offset + paletteOffset;

Expand Down Expand Up @@ -2127,6 +2127,12 @@ HRESULT DirectX::LoadFromTGAFile(
image.Release();
return hr;
}

if ((remaining - paletteOffset) == 0)
{
image.Release();
return HRESULT_E_HANDLE_EOF;
}
}

if (convFlags & CONV_FLAGS_RLE)
Expand Down
Loading