From 1e6e67b38184c7946e8db64cb85e8e8e883a1a1e Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sat, 3 Jan 2026 13:18:03 +0000 Subject: [PATCH] Fix potential access violation when setting null texture on LineGroup in ParticleBuffer --- .../Source/WWVegas/WW3D2/part_buf.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp index 6f8e52b0d59..d78f0e67616 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/part_buf.cpp @@ -270,7 +270,10 @@ ParticleBufferClass::ParticleBufferClass { LineGroup=W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(tex); + // Only set texture if it's not NULL to prevent access violation + if (tex) { + LineGroup->Set_Texture(tex); + } LineGroup->Set_Shader(shader); LineGroup->Set_Line_Mode(LineGroupClass::TETRAHEDRON); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition" ) ); @@ -283,7 +286,10 @@ ParticleBufferClass::ParticleBufferClass { LineGroup=W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(tex); + // Only set texture if it's not NULL to prevent access violation + if (tex) { + LineGroup->Set_Texture(tex); + } LineGroup->Set_Shader(shader); LineGroup->Set_Line_Mode(LineGroupClass::PRISM); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition" ) ); @@ -662,7 +668,11 @@ ParticleBufferClass::ParticleBufferClass(const ParticleBufferClass & src) : WWASSERT(src.LineGroup); LineGroup = W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(src.LineGroup->Peek_Texture()); + // Only set texture if it's not NULL to prevent access violation + TextureClass* srcTexture = src.LineGroup->Peek_Texture(); + if (srcTexture) { + LineGroup->Set_Texture(srcTexture); + } LineGroup->Set_Shader(src.LineGroup->Get_Shader()); LineGroup->Set_Line_Mode(LineGroupClass::TETRAHEDRON); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition") ); @@ -676,7 +686,11 @@ ParticleBufferClass::ParticleBufferClass(const ParticleBufferClass & src) : WWASSERT(src.LineGroup); LineGroup = W3DNEW LineGroupClass(); LineGroup->Set_Flag(LineGroupClass::TRANSFORM, true); - LineGroup->Set_Texture(src.LineGroup->Peek_Texture()); + // Only set texture if it's not NULL to prevent access violation + TextureClass* srcTexture = src.LineGroup->Peek_Texture(); + if (srcTexture) { + LineGroup->Set_Texture(srcTexture); + } LineGroup->Set_Shader(src.LineGroup->Get_Shader()); LineGroup->Set_Line_Mode(LineGroupClass::PRISM); TailPosition = NEW_REF( ShareBufferClass , (MaxNum, "ParticleBufferClass::TailPosition") );