Skip to content

Commit

Permalink
Improve error reporting for TGAs with invalid palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Jan 8, 2025
1 parent 9b4cf59 commit 6d8ed3d
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 6d8ed3d

Please sign in to comment.