From 8f79186b15940eb9a764676483aff522d1123562 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Wed, 8 Jan 2025 14:53:05 -0800 Subject: [PATCH] Improve error reporting for TGAs with invalid palettes (#570) --- .github/workflows/wsl.yml | 2 +- DirectXTex/DirectXTexTGA.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wsl.yml b/.github/workflows/wsl.yml index b58efb0..c6bcbe8 100644 --- a/.github/workflows/wsl.yml +++ b/.github/workflows/wsl.yml @@ -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 diff --git a/DirectXTex/DirectXTexTGA.cpp b/DirectXTex/DirectXTexTGA.cpp index 2390ee0..8f84aa6 100644 --- a/DirectXTex/DirectXTexTGA.cpp +++ b/DirectXTex/DirectXTexTGA.cpp @@ -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(pSource) + offset + paletteOffset; @@ -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)