CScriptMidi: Add destructor implementation

This ensures currently playing track is
stopped, avoiding a UAF in Amuse.
This commit is contained in:
Luke Street 2022-05-12 13:18:12 -04:00
parent 7b6720628c
commit 937aeda51f
2 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,10 @@ CScriptMidi::CScriptMidi(TUniqueId id, const CEntityInfo& info, std::string_view
x34_song = g_SimplePool->GetObj(SObjectTag{FOURCC('CSNG'), csng});
}
CScriptMidi::~CScriptMidi() {
StopInternal(0.f);
}
void CScriptMidi::StopInternal(float fadeTime) {
if (!x3c_handle) {
return;

View File

@ -22,6 +22,7 @@ public:
DEFINE_ENTITY
CScriptMidi(TUniqueId id, const CEntityInfo& info, std::string_view name, bool active, CAssetId csng, float, float,
s32);
~CScriptMidi() override;
void Stop(CStateManager& mgr, float fadeTime);
void Play(CStateManager& mgr, float fadeTime);