halflife
halflife copied to clipboard
Particle manager leaks physics force data memory
The particle manager maintains a list of active physics forces added using this method: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/public/particleman.h#L33
In IParticleMan_Active::Update forces that have timed out are supposed to be removed, but due to faulty logic the memory for these objects isn't actually freed.
Apparently when this code calls delete on the object, it first changes the pointer to the object to null, like this:
ForceMember* object = ...; //Physics force object, obtained earlier on
if (object has timed out)
{
object = nullptr;
delete object;
}
This causes a memory leak that will eventually crash the program.
There does not appear to be any code in official games using this particular method, but any mods that use it will be affected by the leak.