Improve error reporting for TGAs with invalid palettes (#570)

This commit is contained in:
Chuck Walbourn 2025-01-08 14:53:05 -08:00 committed by GitHub
parent 9b4cf594ef
commit 8f79186b15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -30,7 +30,7 @@ jobs:
matrix: matrix:
build_type: [x64-Debug-Linux, x64-Release-Linux] build_type: [x64-Debug-Linux, x64-Release-Linux]
gcc: [10, 11, 12] gcc: [12, 13, 14]
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

View File

@ -1679,7 +1679,7 @@ HRESULT DirectX::LoadFromTGAMemory(
const size_t remaining = size - offset - paletteOffset; const size_t remaining = size - offset - paletteOffset;
if (remaining == 0) if (remaining == 0)
return E_FAIL; return HRESULT_E_HANDLE_EOF;
const void* pPixels = static_cast<const uint8_t*>(pSource) + offset + paletteOffset; const void* pPixels = static_cast<const uint8_t*>(pSource) + offset + paletteOffset;
@ -2127,6 +2127,12 @@ HRESULT DirectX::LoadFromTGAFile(
image.Release(); image.Release();
return hr; return hr;
} }
if ((remaining - paletteOffset) == 0)
{
image.Release();
return HRESULT_E_HANDLE_EOF;
}
} }
if (convFlags & CONV_FLAGS_RLE) if (convFlags & CONV_FLAGS_RLE)