Skip to content

Commit 6d8ed3d

Browse files
committed
Improve error reporting for TGAs with invalid palettes
1 parent 9b4cf59 commit 6d8ed3d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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)