[Scummvm-git-logs] scummvm master -> 18d6b3a6c7815015c019699be2b84e0b5958f03c

athrxx noreply at scummvm.org
Tue Mar 11 14:15:51 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
18d6b3a6c7 SCUMM: fix bug no. 15794


Commit: 18d6b3a6c7815015c019699be2b84e0b5958f03c
    https://github.com/scummvm/scummvm/commit/18d6b3a6c7815015c019699be2b84e0b5958f03c
Author: athrxx (athrxx at scummvm.org)
Date: 2025-03-11T15:15:00+01:00

Commit Message:
SCUMM: fix bug no. 15794

Monkey1-SegaCD crash in IMuseDriver_GMidi::trackMidiState()
when quitting the game.

(regression from adb52bc)

Changed paths:
    engines/scumm/imuse/drivers/midi.cpp


diff --git a/engines/scumm/imuse/drivers/midi.cpp b/engines/scumm/imuse/drivers/midi.cpp
index 89ba484a412..fb2821378f3 100644
--- a/engines/scumm/imuse/drivers/midi.cpp
+++ b/engines/scumm/imuse/drivers/midi.cpp
@@ -389,11 +389,16 @@ IMuseDriver_GMidi::IMuseDriver_GMidi(MidiDriver::DeviceHandle dev, bool rolandGS
 	_imsParts(nullptr), _newSystem(newSystem), _numChannels(16), _notesPlaying(nullptr), _notesSustained(nullptr), _midiRegState(nullptr), _idleChain(nullptr), _activeChain(nullptr), _numVoices(12) {
 	_drv = MidiDriver::createMidi(dev);
 	assert(_drv);
+	_midiRegState = new byte[160];
+	assert(_midiRegState);
+	memset(_midiRegState, 0xFF, 160);
 }
 
 IMuseDriver_GMidi::~IMuseDriver_GMidi() {
 	close();
 	delete _drv;
+	delete[] _midiRegState;
+	_midiRegState = nullptr;
 }
 
 int IMuseDriver_GMidi::open() {
@@ -465,9 +470,6 @@ void IMuseDriver_GMidi::createChannels() {
 		_notesPlaying = new uint16[128]();
 		_notesSustained = new uint16[128]();
 	}
-
-	_midiRegState = new byte[160];
-	memset(_midiRegState, 0xFF, 160);
 }
 
 void IMuseDriver_GMidi::createParts() {
@@ -506,8 +508,6 @@ void IMuseDriver_GMidi::releaseChannels() {
 	_notesPlaying = nullptr;
 	delete[] _notesSustained;
 	_notesSustained = nullptr;
-	delete[] _midiRegState;
-	_midiRegState = nullptr;
 }
 
 void IMuseDriver_GMidi::initDevice() {
@@ -661,6 +661,7 @@ bool IMuseDriver_GMidi::trackMidiState(uint32 b) {
 	byte part = b & 0x0F;
 	b >>= 8; // Switch to para 1
 
+	assert(_midiRegState);
 	byte *var = &_midiRegState[part];
 
 	switch (evt) {




More information about the Scummvm-git-logs mailing list