idSlowChannel::Reset(): Don't memset() the class

it has a member with a vtable that gets overwritten then, that's bad
(even though I've never seen a crash caused by this?!)

Instead set the members to NULL/zero manually
This commit is contained in:
Daniel Gibson 2025-02-28 01:19:35 +01:00
parent b78becde4c
commit 2b20aadda5
2 changed files with 12 additions and 5 deletions

View file

@ -1148,17 +1148,18 @@ idSlowChannel::Reset
===================
*/
void idSlowChannel::Reset() {
memset( this, 0, sizeof( *this ) );
this->chan = chan;
// DG: memset() on this is problematic, because lowpass (SoundFX_LowpassFast) has a vtable
//memset( this, 0, sizeof( *this ) );
active = false;
chan = NULL;
playbackState = triggerOffset = 0;
lowpass.Clear();
curPosition.Set( 0 );
newPosition.Set( 0 );
curSampleOffset = -10000;
newSampleOffset = -10000;
triggerOffset = 0;
}
/*

View file

@ -341,6 +341,12 @@ class SoundFX_LowpassFast : public SoundFX {
public:
virtual void ProcessSample( float* in, float* out );
void SetParms( float p1 = 0, float p2 = 0, float p3 = 0 );
void Clear() {
freq = res = 0.0f;
a1 = a2 = a3 = 0.0f;
b1 = b2 = 0.0f;
}
};
class SoundFX_Comb : public SoundFX {