[Scummvm-git-logs] scummvm master -> 92e54f4026fdb7b9f90e20d84696f2772414ff59
sluicebox
noreply at scummvm.org
Wed Sep 18 08:10:27 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0887df6b39 WIN32: Fix memory leak in WindowsFilesystemNode
a8006eda16 SCI: Fix memory leaks in GfxMenu when restarting
92e54f4026 SCI: Fix memory leak in EngineState when restarting
Commit: 0887df6b39829734eb934e5471c27ccd88fe097d
https://github.com/scummvm/scummvm/commit/0887df6b39829734eb934e5471c27ccd88fe097d
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-18T01:06:59-07:00
Commit Message:
WIN32: Fix memory leak in WindowsFilesystemNode
20 years old: be58f22feb25ab840282fd38517c6c48db1b6c01
Changed paths:
backends/fs/windows/windows-fs.cpp
diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp
index aed7da04ad1..565ebc9bf7f 100644
--- a/backends/fs/windows/windows-fs.cpp
+++ b/backends/fs/windows/windows-fs.cpp
@@ -203,7 +203,7 @@ AbstractFSNode *WindowsFilesystemNode::getParent() const {
if (_isPseudoRoot)
return nullptr;
- WindowsFilesystemNode *p = new WindowsFilesystemNode();
+ WindowsFilesystemNode *p;
if (_path.size() > 3) {
const char *start = _path.c_str();
const char *end = lastPathComponent(_path, '\\');
@@ -214,6 +214,9 @@ AbstractFSNode *WindowsFilesystemNode::getParent() const {
p->_isDirectory = true;
p->_displayName = lastPathComponent(p->_path, '\\');
p->_isPseudoRoot = false;
+ } else {
+ // pseudo root
+ p = new WindowsFilesystemNode();
}
return p;
Commit: a8006eda16de32944587fc04d6787f48381fe60b
https://github.com/scummvm/scummvm/commit/a8006eda16de32944587fc04d6787f48381fe60b
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-18T01:07:00-07:00
Commit Message:
SCI: Fix memory leaks in GfxMenu when restarting
Changed paths:
engines/sci/graphics/menu.cpp
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index 5d0e442efc3..91728cb4021 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -51,19 +51,18 @@ GfxMenu::GfxMenu(EventManager *event, SegManager *segMan, GfxPorts *ports, GfxPa
}
GfxMenu::~GfxMenu() {
- for (GuiMenuItemList::iterator itemIter = _itemList.begin(); itemIter != _itemList.end(); ++itemIter)
- delete *itemIter;
-
- _itemList.clear();
-
- for (GuiMenuList::iterator menuIter = _list.begin(); menuIter != _list.end(); ++menuIter)
- delete *menuIter;
-
- _list.clear();
+ reset();
}
void GfxMenu::reset() {
+ for (GuiMenuList::iterator i = _list.begin(); i != _list.end(); ++i) {
+ delete *i;
+ }
_list.clear();
+
+ for (GuiMenuItemList::iterator i = _itemList.begin(); i != _itemList.end(); ++i) {
+ delete *i;
+ }
_itemList.clear();
// We actually set active item in here and remember last selection of the
Commit: 92e54f4026fdb7b9f90e20d84696f2772414ff59
https://github.com/scummvm/scummvm/commit/92e54f4026fdb7b9f90e20d84696f2772414ff59
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2024-09-18T01:07:00-07:00
Commit Message:
SCI: Fix memory leak in EngineState when restarting
Changed paths:
engines/sci/engine/savegame.cpp
engines/sci/engine/state.cpp
engines/sci/engine/state.h
engines/sci/sci.cpp
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 3070095fd34..506c614e840 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -1525,8 +1525,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
g_sci->_soundCmd->reconstructPlayList();
// Message state:
- delete s->_msgState;
- s->_msgState = new MessageState(s->_segMan);
+ s->initMessageState();
// System strings:
s->_segMan->initSysStrings();
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index b0bd05a23d6..c7f9dbdd68f 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -176,6 +176,11 @@ void EngineState::initGlobals() {
}
}
+void EngineState::initMessageState() {
+ delete _msgState;
+ _msgState = new MessageState(_segMan);
+}
+
uint16 EngineState::currentRoomNumber() const {
return variables[VAR_GLOBAL][kGlobalVarNewRoomNo].toUint16();
}
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index b84a2a08f32..58c5eb9b20c 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -190,6 +190,7 @@ struct EngineState : public Common::Serializable {
int gcCountDown; /**< Number of kernel calls until next gc */
MessageState *_msgState;
+ void initMessageState();
// MemorySegment provides access to a 256-byte block of memory that remains
// intact across restarts and restores
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 3feae4168c2..366e1d539b6 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -567,7 +567,7 @@ bool SciEngine::initGame() {
int script0Segment = _gamestate->_segMan->getScriptSegment(0, SCRIPT_GET_LOCK);
DataStack *stack = _gamestate->_segMan->allocateStack(VM_STACK_SIZE);
- _gamestate->_msgState = new MessageState(_gamestate->_segMan);
+ _gamestate->initMessageState();
_gamestate->gcCountDown = GC_INTERVAL - 1;
// Script 0 should always be at segment 1
More information about the Scummvm-git-logs
mailing list