From 20a4deae768e25c7925e0807290ce1d17163a359 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sun, 5 Oct 2025 01:56:22 +0000 Subject: [PATCH] DX8: Handle failure of CreateImageSurface --- .../Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 9 ++++++++- .../Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index ccd6c9df7f9..41994fd362d 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -2371,7 +2371,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned // Paletted surfaces not supported! WWASSERT(format!=D3DFMT_P8); - DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface)); + HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface); + number_of_DX8_calls++; + + if (FAILED(hr)) { + // Log the error and return NULL to indicate failure + Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__); + return NULL; + } return surface; } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp index 16fe4e80eb0..32a9e2659d4 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp @@ -2943,7 +2943,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned // Paletted surfaces not supported! WWASSERT(format!=D3DFMT_P8); - DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface)); + HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface); + number_of_DX8_calls++; + + if (FAILED(hr)) { + // Log the error and return NULL to indicate failure + Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__); + return NULL; + } return surface; }