Skip to content

Commit

Permalink
Improve error reporting for TGAs with invalid palettes (#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Jan 8, 2025
1 parent 9b4cf59 commit 8f79186
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wsl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

matrix:
build_type: [x64-Debug-Linux, x64-Release-Linux]
gcc: [10, 11, 12]
gcc: [12, 13, 14]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
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 8f79186

Please sign in to comment.