Skip to content

Commit 8f79186

Browse files
authored
Improve error reporting for TGAs with invalid palettes (#570)
1 parent 9b4cf59 commit 8f79186

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/wsl.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
matrix:
3232
build_type: [x64-Debug-Linux, x64-Release-Linux]
33-
gcc: [10, 11, 12]
33+
gcc: [12, 13, 14]
3434

3535
steps:
3636
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

DirectXTex/DirectXTexTGA.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ HRESULT DirectX::LoadFromTGAMemory(
16791679

16801680
const size_t remaining = size - offset - paletteOffset;
16811681
if (remaining == 0)
1682-
return E_FAIL;
1682+
return HRESULT_E_HANDLE_EOF;
16831683

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

@@ -2127,6 +2127,12 @@ HRESULT DirectX::LoadFromTGAFile(
21272127
image.Release();
21282128
return hr;
21292129
}
2130+
2131+
if ((remaining - paletteOffset) == 0)
2132+
{
2133+
image.Release();
2134+
return HRESULT_E_HANDLE_EOF;
2135+
}
21302136
}
21312137

21322138
if (convFlags & CONV_FLAGS_RLE)

0 commit comments

Comments
 (0)