diff --git a/source/audiolib/src/flac.cpp b/source/audiolib/src/flac.cpp index 36d5de001..6ead5eece 100644 --- a/source/audiolib/src/flac.cpp +++ b/source/audiolib/src/flac.cpp @@ -651,15 +651,20 @@ void MV_ReleaseFLACVoice(VoiceNode *voice) return; } + voice->rawdataptr = 0; if (fd->stream != NULL) { - FLAC__stream_decoder_finish(fd->stream); - FLAC__stream_decoder_delete(fd->stream); + auto stream = fd->stream; + fd->stream = nullptr; + FLAC__stream_decoder_finish(stream); + FLAC__stream_decoder_delete(stream); } - free(fd->block); + auto block = fd->block; + voice->length = 0; + voice->sound = nullptr; + fd->block = nullptr; + free(block); free(fd); - - voice->rawdataptr = 0; } #else #include "_multivc.h" diff --git a/source/audiolib/src/vorbis.cpp b/source/audiolib/src/vorbis.cpp index ceeee9266..9894e7ef8 100644 --- a/source/audiolib/src/vorbis.cpp +++ b/source/audiolib/src/vorbis.cpp @@ -460,10 +460,11 @@ void MV_ReleaseVorbisVoice( VoiceNode * voice ) auto vd = (vorbis_data *)voice->rawdataptr; + voice->rawdataptr = 0; + voice->length = 0; + voice->sound = nullptr; ov_clear(&vd->vf); free(vd); - - voice->rawdataptr = 0; } #else #include "_multivc.h" diff --git a/source/audiolib/src/xa.cpp b/source/audiolib/src/xa.cpp index 30385843b..b44f75299 100644 --- a/source/audiolib/src/xa.cpp +++ b/source/audiolib/src/xa.cpp @@ -483,7 +483,8 @@ void MV_ReleaseXAVoice( VoiceNode * voice ) return; } - free(xad); - voice->rawdataptr = 0; + voice->length = 0; + voice->sound = nullptr; + free(xad); } diff --git a/source/audiolib/src/xmp.cpp b/source/audiolib/src/xmp.cpp index f22263d90..b904c1932 100644 --- a/source/audiolib/src/xmp.cpp +++ b/source/audiolib/src/xmp.cpp @@ -196,6 +196,8 @@ void MV_ReleaseXMPVoice(VoiceNode * voice) return; voice->rawdataptr = 0; + voice->length = 0; + voice->sound = nullptr; xmp_end_player(xmpd->context); xmp_release_module(xmpd->context);