[Scummvm-git-logs] scummvm master -> 93986853befec9729b6184c8c82ba17bda38bfaf
mgerhardy
noreply at scummvm.org
Thu Jul 16 08:26:43 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:
cfd0d483e6 MACS2: plug memory leak and minor cleanup
9038ffd8e5 MACS2: fixed CID 1663630
777f42c7e4 MACS2: fixed CID 1663628 Overflowed integer argument
92a00e5f4b MACS2: fixed CID 1663607 Unchecked return value
93986853be MACS2: moved member into into class declaration
Commit: cfd0d483e6aa3bba85cfb4e91527770a64d7065f
https://github.com/scummvm/scummvm/commit/cfd0d483e6aa3bba85cfb4e91527770a64d7065f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-16T10:26:22+02:00
Commit Message:
MACS2: plug memory leak and minor cleanup
Changed paths:
engines/macs2/events.cpp
engines/macs2/events.h
engines/macs2/gameobjects.cpp
engines/macs2/gameobjects.h
diff --git a/engines/macs2/events.cpp b/engines/macs2/events.cpp
index 953b2adf458..61169253c2d 100644
--- a/engines/macs2/events.cpp
+++ b/engines/macs2/events.cpp
@@ -31,7 +31,7 @@ namespace Macs2 {
Events *g_events;
-Events::Events() : UIElement("Root", nullptr), currentMillis(0) {
+Events::Events() : UIElement("Root", nullptr) {
g_events = this;
}
@@ -76,9 +76,9 @@ void Events::runGame() {
currentMillis = g_system->getMillis();
// Accumulate timer ticks based on elapsed wall-clock time
- uint32 elapsed = currentMillis - lastTickTime;
+ const uint32 elapsed = currentMillis - lastTickTime;
if (elapsed >= kTimerTickMs) {
- uint16 ticks = elapsed / kTimerTickMs;
+ const uint16 ticks = elapsed / kTimerTickMs;
timerTickCounter += ticks;
lastTickTime += ticks * kTimerTickMs;
}
@@ -89,7 +89,7 @@ void Events::runGame() {
doTick = true;
break;
case 2: // slow mode: tick when counter >= 0x12
- doTick = (timerTickCounter >= 0x12);
+ doTick = (timerTickCounter >= 0x12); // TODO: this is running at different speed compared to running this in dosbox
break;
default: // normal: tick when counter > 1
doTick = (timerTickCounter > 1);
diff --git a/engines/macs2/events.h b/engines/macs2/events.h
index 1116b84a2ee..c7fab2c4b38 100644
--- a/engines/macs2/events.h
+++ b/engines/macs2/events.h
@@ -283,7 +283,7 @@ public:
virtual ~Events();
// TODO: Consider a better place
- uint32 currentMillis;
+ uint32 currentMillis = 0;
/**
* Main game loop
diff --git a/engines/macs2/gameobjects.cpp b/engines/macs2/gameobjects.cpp
index a7451b0a2f6..3a4cb0ad45d 100644
--- a/engines/macs2/gameobjects.cpp
+++ b/engines/macs2/gameobjects.cpp
@@ -478,6 +478,10 @@ Macs2::AnimationReader::AnimationReader(const Common::Array<uint8> &blob) {
_readStream = new Common::MemoryReadStreamEndian(blob.data(), blob.size(), false);
}
+Macs2::AnimationReader::~AnimationReader() {
+ delete _readStream;
+}
+
uint16 Macs2::AnimationReader::readNumAnimations() {
// Read the header
diff --git a/engines/macs2/gameobjects.h b/engines/macs2/gameobjects.h
index 0462f4e40b6..1d0482b5602 100644
--- a/engines/macs2/gameobjects.h
+++ b/engines/macs2/gameobjects.h
@@ -72,6 +72,7 @@ public:
// TODO: Can the init list also go into the cpp file?
AnimationReader(const Common::Array<uint8> &blob);
+ ~AnimationReader();
uint16 readNumAnimations();
Commit: 9038ffd8e5d4a8cbe7c06dc6e0ba9d5ac300616f
https://github.com/scummvm/scummvm/commit/9038ffd8e5d4a8cbe7c06dc6e0ba9d5ac300616f
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-16T10:26:22+02:00
Commit Message:
MACS2: fixed CID 1663630
The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In Macs2::âMacs2Engine::âsyncGame(Common::âSerializer &): Leak of memory or pointers to system resources (CWE-404)
Changed paths:
engines/macs2/saveload.cpp
diff --git a/engines/macs2/saveload.cpp b/engines/macs2/saveload.cpp
index e18e0af4fe9..53a3a0895e3 100644
--- a/engines/macs2/saveload.cpp
+++ b/engines/macs2/saveload.cpp
@@ -848,8 +848,7 @@ Common::Error Macs2Engine::syncGame(Common::Serializer &s) {
// The cursor slot is only populated when clicking an inventory item in the panel;
// after loading a save with mouseMode==UseInventory, the slot is empty.
if (_scriptExecutor->_cursorMode == Script::MouseMode::UseInventory && view1->_activeInventoryItem != nullptr) {
- AnimFrame *icon = view1->getInventoryIcon(view1->_activeInventoryItem);
- if (icon != nullptr) {
+ if (AnimFrame *icon = view1->getInventoryIcon(view1->_activeInventoryItem)) {
int cursorSlot = (int)Script::MouseMode::UseInventory - 1;
_imageResources[cursorSlot] = *icon;
}
Commit: 777f42c7e4a49e8771e49da582fa55836f38a0c8
https://github.com/scummvm/scummvm/commit/777f42c7e4a49e8771e49da582fa55836f38a0c8
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-16T10:26:22+02:00
Commit Message:
MACS2: fixed CID 1663628 Overflowed integer argument
Changed paths:
engines/macs2/scriptexecutor.cpp
diff --git a/engines/macs2/scriptexecutor.cpp b/engines/macs2/scriptexecutor.cpp
index 5bf1bdb65f9..0734b2c504b 100644
--- a/engines/macs2/scriptexecutor.cpp
+++ b/engines/macs2/scriptexecutor.cpp
@@ -362,10 +362,10 @@ void ScriptExecutor::scriptPrintString(bool alignRight) {
currentView->_uiBackgroundRestorePending = false;
}
- uint16 x = scriptReadValue16();
- uint16 y = scriptReadValue16();
- uint16 bp2 = readUint16();
- uint16 bp4 = readUint16();
+ const uint16 x = scriptReadValue16();
+ const uint16 y = scriptReadValue16();
+ const uint16 bp2 = readUint16();
+ const uint16 bp4 = readUint16();
debugC(kDebugScript, "SCRIPT::printString(x=%u, y=%u, strOffset=%u, numLines=%u, alignRight=%d)", x, y, bp2, bp4, alignRight);
@@ -378,13 +378,16 @@ void ScriptExecutor::scriptPrintString(bool alignRight) {
delete s;
}
+ int stringBoxX = x;
+ const int stringBoxY = y;
if (alignRight) {
- x -= g_engine->measureStrings(strings) + 0x12;
+ const int totalWidth = g_engine->measureStrings(strings) + 0x12;
+ stringBoxX -= totalWidth;
}
if (currentView) {
// Binary scriptPrintString (1008:a9fa): renders text, then sets g_wIsShowingTextBox=1
- currentView->_stringBoxPosition = Common::Point(x, y);
+ currentView->_stringBoxPosition = Common::Point(stringBoxX, stringBoxY);
currentView->_drawnStringBox = strings;
currentView->_isShowingTextBox = true;
currentView->currentSpeechActData.speaker = nullptr;
Commit: 92a00e5f4b026eb5c93197ff8d1400957b5a7018
https://github.com/scummvm/scummvm/commit/92a00e5f4b026eb5c93197ff8d1400957b5a7018
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-16T10:26:22+02:00
Commit Message:
MACS2: fixed CID 1663607 Unchecked return value
Changed paths:
engines/macs2/view1.cpp
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index 787bc03647c..c6f7bd1c09c 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -759,13 +759,18 @@ void View1::showStringBox(const Common::StringArray &sa) {
void View1::drawPathfindingPoints(Graphics::ManagedSurface &s) {
GlyphData xData;
- g_engine->findGlyph('x', xData);
+ int xOffset = 0;
+ int yOffset = 0;
+ if (g_engine->findGlyph('x', xData)) {
+ xOffset = xData._width / 2;
+ yOffset = xData._height / 2;
+ }
for (int i = 0; i < 16; i++) {
PathfindingPoint ¤t = g_engine->pathfindingPoints[i];
- renderString(current._position.x - xData._width * 0.5, current._position.y - xData._height * 0.5, "x");
+ renderString(current._position.x - xOffset, current._position.y - yOffset, "x");
Common::String number = Common::String::format("%u", i);
- renderString(current._position.x - xData._width * 0.5 + 10, current._position.y - xData._height * 0.5 + 10, number.c_str());
+ renderString(current._position.x - xOffset + 10, current._position.y - yOffset + 10, number.c_str());
for (uint8 adjacentIndex : current._adjacentPoints) {
if (adjacentIndex >= g_engine->pathfindingPoints.size()) {
Commit: 93986853befec9729b6184c8c82ba17bda38bfaf
https://github.com/scummvm/scummvm/commit/93986853befec9729b6184c8c82ba17bda38bfaf
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2026-07-16T10:26:22+02:00
Commit Message:
MACS2: moved member into into class declaration
Changed paths:
engines/macs2/view1.cpp
engines/macs2/view1.h
diff --git a/engines/macs2/view1.cpp b/engines/macs2/view1.cpp
index c6f7bd1c09c..57bb1b19bd2 100644
--- a/engines/macs2/view1.cpp
+++ b/engines/macs2/view1.cpp
@@ -3427,8 +3427,7 @@ bool Character::isWalkable(const Common::Point &p) const {
return Macs2Engine::isWalkabilityWalkable(lookupWalkability(p));
}
-Character::Character() : _startTime(0), _duration(0) {
- _pathfindingOverlay = Common::Array<uint8>(kScreenWidth * kGameHeight, 0);
+Character::Character() : _pathfindingOverlay(kScreenWidth * kGameHeight, 0) {
}
bool Character::calculatePath(Common::Point target) {
diff --git a/engines/macs2/view1.h b/engines/macs2/view1.h
index e75ebedc758..8941aad3339 100644
--- a/engines/macs2/view1.h
+++ b/engines/macs2/view1.h
@@ -56,8 +56,8 @@ class Character {
private:
Common::Point _startPosition;
- uint32 _startTime;
- uint32 _duration;
+ uint32 _startTime = 0;
+ uint32 _duration = 0;
bool _lerpIgnoresObstacles = false;
More information about the Scummvm-git-logs
mailing list