[Scummvm-git-logs] scummvm master -> 1154406488116215fe04d94609b1baa9e2542ab1
sluicebox
noreply at scummvm.org
Sun Mar 8 05:40:45 UTC 2026
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7caf152a46 TINSEL: Fix memory leak when initializing background
9c74e136cc TINSEL: Fix memory leak when playing DW1 Mac music
a591a5818f TINSEL: Fix midi buffer memory leak
48d861f1d3 TINSEL: Fix coroutine memory leaks
1154406488 TINSEL: Fix memory leak when fading screen
Commit: 7caf152a460bffee1c9968dd23715cda617ab12a
https://github.com/scummvm/scummvm/commit/7caf152a460bffee1c9968dd23715cda617ab12a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-07T23:39:53-06:00
Commit Message:
TINSEL: Fix memory leak when initializing background
Changed paths:
engines/tinsel/background.cpp
engines/tinsel/background.h
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/background.cpp b/engines/tinsel/background.cpp
index c7dac05e31f..8eb53d7f26e 100644
--- a/engines/tinsel/background.cpp
+++ b/engines/tinsel/background.cpp
@@ -40,10 +40,16 @@ Background::Background(Font* font) : _font(font), _pCurBgnd(nullptr), _hBgPal(0)
}
}
+Background::~Background() {
+ ResetBackground();
+}
+
/**
* Called to initialize a background.
*/
void Background::InitBackground() {
+ ResetBackground();
+
// set current background
_pCurBgnd = new BACKGND();
_pCurBgnd->rgbSkyColor = BLACK;
diff --git a/engines/tinsel/background.h b/engines/tinsel/background.h
index 5a3120e5d16..b06f4713a31 100644
--- a/engines/tinsel/background.h
+++ b/engines/tinsel/background.h
@@ -81,6 +81,7 @@ class Font;
class Background {
public:
Background(Font* font);
+ ~Background();
void InitBackground();
@@ -92,7 +93,6 @@ public:
void DropBackground();
void ResetBackground() {
- _pCurBgnd->fieldArray.clear();
delete _pCurBgnd;
_pCurBgnd = nullptr;
}
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 092d3dc0d4a..9e8144b7393 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -1152,8 +1152,6 @@ Common::Error TinselEngine::run() {
_vm->_config->writeToDisk();
EndScene();
- if (_bg)
- _bg->ResetBackground();
return Common::kNoError;
}
Commit: 9c74e136cc9ca64d068aab0c93c0fd9b7324ed78
https://github.com/scummvm/scummvm/commit/9c74e136cc9ca64d068aab0c93c0fd9b7324ed78
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-07T23:39:54-06:00
Commit Message:
TINSEL: Fix memory leak when playing DW1 Mac music
Changed paths:
engines/tinsel/sound.cpp
diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp
index 1729378a658..19887cca31e 100644
--- a/engines/tinsel/sound.cpp
+++ b/engines/tinsel/sound.cpp
@@ -188,7 +188,7 @@ void SoundManager::playDW1MacMusic(Common::File &s, uint32 length) {
if (s.read(soundData, length) != length)
error(FILE_IS_CORRUPT, MIDI_FILE);
- Common::SeekableReadStream *memStream = new Common::MemoryReadStream(soundData, length);
+ Common::SeekableReadStream *memStream = new Common::MemoryReadStream(soundData, length, DisposeAfterUse::YES);
Audio::SoundHandle *handle = &_channels[kChannelDW1MacMusic].handle;
Commit: a591a5818fea2a61eb70662a09bdf934f4b97d32
https://github.com/scummvm/scummvm/commit/a591a5818fea2a61eb70662a09bdf934f4b97d32
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-07T23:39:54-06:00
Commit Message:
TINSEL: Fix midi buffer memory leak
Changed paths:
engines/tinsel/music.h
diff --git a/engines/tinsel/music.h b/engines/tinsel/music.h
index 27885cf47e3..eaa1a437762 100644
--- a/engines/tinsel/music.h
+++ b/engines/tinsel/music.h
@@ -40,6 +40,10 @@ public:
_midiBuffer.size = 0;
}
+ ~Music() {
+ DeleteMidiBuffer();
+ }
+
bool PlayMidiSequence( // Plays the specified MIDI sequence through the sound driver
uint32 dwFileOffset, // handle of MIDI sequence data
bool bLoop); // Whether to loop the sequence
Commit: 48d861f1d3a0ddf46a7a42cea8cceceb758091f0
https://github.com/scummvm/scummvm/commit/48d861f1d3a0ddf46a7a42cea8cceceb758091f0
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-07T23:39:55-06:00
Commit Message:
TINSEL: Fix coroutine memory leaks
Changed paths:
engines/tinsel/tinsel.cpp
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 9e8144b7393..f4807ac6df6 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -978,6 +978,8 @@ TinselEngine::~TinselEngine() {
RebootTimers(); // timers.cpp
ResetVarsTinlib(); // tinlib.cpp
ResetVarsTinsel(); // tinsel.cpp
+
+ CoroScheduler.destroy();
}
Common::String TinselEngine::getSavegameFilename(int16 saveNum) const {
Commit: 1154406488116215fe04d94609b1baa9e2542ab1
https://github.com/scummvm/scummvm/commit/1154406488116215fe04d94609b1baa9e2542ab1
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2026-03-07T23:39:55-06:00
Commit Message:
TINSEL: Fix memory leak when fading screen
When one screen fades out and the next screen fades in, the second fade
interrupts the first coroutine. FadeProcess allocates a palette object
and only freed it at the end of the function, but the end of the
function is never reached if the coroutine is interrupted.
Now the relevant palette data is copied to local coroutine variables
and the allocated object is immediately freed.
Changed paths:
engines/tinsel/faders.cpp
diff --git a/engines/tinsel/faders.cpp b/engines/tinsel/faders.cpp
index 174bdfb983c..41c6cca93c6 100644
--- a/engines/tinsel/faders.cpp
+++ b/engines/tinsel/faders.cpp
@@ -93,6 +93,8 @@ static void FadePalette(COLORREF *pNew, COLORREF *pOrig, int numColors, uint32 m
static void FadeProcess(CORO_PARAM, const void *param) {
// COROUTINE
CORO_BEGIN_CONTEXT;
+ COLORREF origRGB[MAX_COLORS]; // local copy of original palette
+ int32 numColors; // number of colors in original palette
COLORREF fadeRGB[MAX_COLORS]; // local copy of palette
const long *pColMult; // pointer to color multiplier table
PALETTE *pPalette; // pointer to palette
@@ -107,8 +109,13 @@ static void FadeProcess(CORO_PARAM, const void *param) {
// Note that this palette is being faded
FadingPalette(pFade->pPalQ, true);
- // get pointer to palette - reduce pointer indirection a bit
+ // get palette - reduce pointer indirection a bit.
+ // copy to a local array so that palette can be immediately deleted,
+ // otherwise it will leak if coroutine is interrupted by another fade.
_ctx->pPalette = _vm->_handle->GetPalette(pFade->pPalQ->hPal);
+ memcpy(_ctx->origRGB, _ctx->pPalette->palRGB, _ctx->pPalette->numColors * sizeof(COLORREF));
+ _ctx->numColors = _ctx->pPalette->numColors;
+ delete _ctx->pPalette;
for (_ctx->pColMult = pFade->pColorMultTable; *_ctx->pColMult >= 0; _ctx->pColMult++) {
// go through all multipliers in table - until a negative entry
@@ -118,11 +125,11 @@ static void FadeProcess(CORO_PARAM, const void *param) {
FadePalette(_ctx->fadeRGB, pFade->pPalQ->palRGB,
pFade->pPalQ->numColors, (uint32) *_ctx->pColMult);
else
- FadePalette(_ctx->fadeRGB, _ctx->pPalette->palRGB,
- _ctx->pPalette->numColors, (uint32) *_ctx->pColMult);
+ FadePalette(_ctx->fadeRGB, _ctx->origRGB,
+ _ctx->numColors, (uint32) *_ctx->pColMult);
// send new palette to video DAC
- UpdateDACqueue(pFade->pPalQ->posInDAC, _ctx->pPalette->numColors, _ctx->fadeRGB);
+ UpdateDACqueue(pFade->pPalQ->posInDAC, _ctx->numColors, _ctx->fadeRGB);
// allow time for video DAC to be updated
CORO_SLEEP(1);
@@ -132,8 +139,6 @@ static void FadeProcess(CORO_PARAM, const void *param) {
// Note that this palette is being faded
FadingPalette(pFade->pPalQ, false);
- delete _ctx->pPalette;
-
CORO_END_CODE;
}
More information about the Scummvm-git-logs
mailing list