From 7de4aabafcde9c3d34bdd3460303cb009ac98828 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Thu, 3 Sep 2026 02:59:39 +0000 Subject: [PATCH] fix(rendering): Prevent crash on null texture surface creation in Build_Textures --- .../Source/WWVegas/WW3D2/render2dsentence.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp index 64001c0bc07..a80515b45f5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp @@ -359,8 +359,27 @@ Render2DSentenceClass::Build_Textures () // Create the new texture // TextureClass *new_texture = W3DNEW TextureClass (desc.Width, desc.Width, WW3D_FORMAT_A4R4G4B4, MIP_LEVELS_1); + + // + // Validate that texture allocation succeeded + // + if (new_texture == nullptr) { + REF_PTR_RELEASE (curr_surface); + continue; + } + SurfaceClass *texture_surface = new_texture->Get_Surface_Level (); + // + // Validate that the texture surface is valid before using it + // + if (texture_surface == nullptr || !texture_surface->Is_Valid()) { + REF_PTR_RELEASE (texture_surface); + REF_PTR_RELEASE (new_texture); + REF_PTR_RELEASE (curr_surface); + continue; + } + new_texture->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); new_texture->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); new_texture->Get_Filter().Set_Min_Filter(TextureFilterClass::FILTER_TYPE_NONE);