From 2b20aadda55c8e0cd552684130d5e8181a8efff7 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Fri, 28 Feb 2025 01:19:35 +0100 Subject: [PATCH] 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 --- neo/sound/snd_emitter.cpp | 11 ++++++----- neo/sound/snd_local.h | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/neo/sound/snd_emitter.cpp b/neo/sound/snd_emitter.cpp index bd241b81..eea7c3db 100644 --- a/neo/sound/snd_emitter.cpp +++ b/neo/sound/snd_emitter.cpp @@ -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; } /* diff --git a/neo/sound/snd_local.h b/neo/sound/snd_local.h index b4fe01b2..808faaaf 100644 --- a/neo/sound/snd_local.h +++ b/neo/sound/snd_local.h @@ -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 {