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);