[Scummvm-git-logs] scummvm master -> 05e85b398697f0c45c694b5e890adf9ace781c7d

kelmer44 noreply at scummvm.org
Mon Oct 6 07:49:27 UTC 2025


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

Summary:
05e85b3986 TOT: Ensures initialization of all Tot class members (as per coverity)


Commit: 05e85b398697f0c45c694b5e890adf9ace781c7d
    https://github.com/scummvm/scummvm/commit/05e85b398697f0c45c694b5e890adf9ace781c7d
Author: kelmer (kelmer at gmail.com)
Date: 2025-10-06T09:49:17+02:00

Commit Message:
TOT: Ensures initialization of all Tot class members (as per coverity)

Changed paths:
    engines/tot/forest.cpp
    engines/tot/saveload.cpp
    engines/tot/tot.cpp
    engines/tot/tot.h
    engines/tot/types.h


diff --git a/engines/tot/forest.cpp b/engines/tot/forest.cpp
index f1aaf605ed0..7bbba29cd74 100644
--- a/engines/tot/forest.cpp
+++ b/engines/tot/forest.cpp
@@ -151,6 +151,8 @@ void readTree(Common::SeekableReadStream &stream, Tree &a, uint position) {
 		} while (expresion[pos++] != '@');
 
 		int nIndex = tmpExpression.find('N');
+		if (nIndex < 0)
+			break;
 		strInd = tmpExpression.substr(0, nIndex - 1);
 
 		data.spoken = tmpExpression[nIndex - 1];
diff --git a/engines/tot/saveload.cpp b/engines/tot/saveload.cpp
index 06cd148bb0e..7c6fa226e18 100644
--- a/engines/tot/saveload.cpp
+++ b/engines/tot/saveload.cpp
@@ -572,6 +572,7 @@ Common::String drawAndSelectSaves(Common::StringArray saves, uint selectedGame)
 	g_engine->_mouse->hide();
 	const char *availableText = getHardcodedTextsByCurrentLanguage()[11];
 	uint size = saves.size();
+	ExtendedSavegameHeader header;
 	for (uint i = 0; i < 6; i++) {
 		int color = i == selectedGame ? 255 : 253;
 		if (i < size) {
@@ -579,7 +580,6 @@ Common::String drawAndSelectSaves(Common::StringArray saves, uint selectedGame)
 			if (!in) {
 				warning("Could not open save file: %s", saves[i].c_str());
 			}
-			ExtendedSavegameHeader header;
 			bool result = g_engine->getMetaEngine()->readSavegameHeader(in, &header, true);
 			euroText(65, 29 + (i * 15), result ? header.description.c_str() : saves[i].c_str(), color);
 		} else {
@@ -587,8 +587,6 @@ Common::String drawAndSelectSaves(Common::StringArray saves, uint selectedGame)
 		}
 	}
 
-	ExtendedSavegameHeader header;
-
 	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(saves[selectedGame]);
 	bool result = g_engine->getMetaEngine()->readSavegameHeader(in, &header, true);
 
diff --git a/engines/tot/tot.cpp b/engines/tot/tot.cpp
index 60769aac765..4576931a39b 100644
--- a/engines/tot/tot.cpp
+++ b/engines/tot/tot.cpp
@@ -49,6 +49,17 @@ TotEngine::TotEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(
 	_rooms = nullptr;
 	_conversationData = nullptr;
 	_sceneObjectsData = nullptr;
+
+	for (uint dir = 0; dir < 4; dir++) {
+		for (uint frame = 0; frame < kWalkFrameCount + 30; frame++) {
+			_mainCharAnimation.bitmap[dir][frame] = nullptr;
+		}
+	}
+	for (uint dir = 0; dir < 4; dir++) {
+		for (uint frame = 0; frame < kWalkFrameCount + 30; frame++) {
+			_secondaryAnimation.bitmap[dir][frame] = nullptr;
+		}
+	}
 }
 
 TotEngine::~TotEngine() {
diff --git a/engines/tot/tot.h b/engines/tot/tot.h
index a6cd91c6e5f..e01aaee0237 100644
--- a/engines/tot/tot.h
+++ b/engines/tot/tot.h
@@ -235,7 +235,7 @@ public:
 	/**
 	 * Keeps an array of all inventory icon bitmaps
 	 */
-	byte *_inventoryIconBitmaps[kInventoryIconCount];
+	byte *_inventoryIconBitmaps[kInventoryIconCount] = { nullptr };
 	/**
 	 * Position within inventory
 	 */
@@ -244,9 +244,9 @@ public:
 	 * Animation sequences
 	 */
 	CharacterAnim _mainCharAnimation;
-	uint _mainCharFrameSize;
+	uint _mainCharFrameSize = 0;
 	SecondaryAnim _secondaryAnimation;
-	uint _secondaryAnimFrameSize;
+	uint _secondaryAnimFrameSize = 0;
 	/**
 	 * Currently selected action.
 	 */
@@ -424,29 +424,29 @@ public:
 	/**
 	 * Bitmaps of screenobjects
 	 */
-	byte *_screenLayers[kNumScreenOverlays];
+	byte *_screenLayers[kNumScreenOverlays] =  { nullptr };
 	/**
 	 * Current frame of main character
 	 */
-	byte *_curCharacterAnimationFrame;
+	byte *_curCharacterAnimationFrame = nullptr;
 	/**
 	 * Current frame of secondary animation
 	 */
-	byte *_curSecondaryAnimationFrame;
+	byte *_curSecondaryAnimationFrame = nullptr;
 
 	/**
 	 * Pointer storing the screen as it displays on the game
 	 */
-	byte *_sceneBackground;
+	byte *_sceneBackground = nullptr;
 
 	/**
 	 * Dirty patch of screen to repaint on every frame
 	 */
-	byte *_characterDirtyRect;
+	byte *_characterDirtyRect = nullptr;
 	/**
 	 * Stores a copy of the background bitmap
 	 */
-	byte *_backgroundCopy;
+	byte *_backgroundCopy = nullptr;
 
 	uint _currentRoomNumber = 0;
 
@@ -472,7 +472,7 @@ public:
 	 * Calculated using the position of the character + dimension
 	 */
 	uint _dirtyMainSpriteX2 = 0, _dirtyMainSpriteY2 = 0;
-	byte *_spriteBackground;
+	byte *_spriteBackground = nullptr;
 public:
 	TotEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~TotEngine() override;
diff --git a/engines/tot/types.h b/engines/tot/types.h
index 040d1743771..87f8a794562 100644
--- a/engines/tot/types.h
+++ b/engines/tot/types.h
@@ -93,16 +93,16 @@ enum TRAJECTORIES_OP {
 };
 
 struct ObjectInfo {
-	uint16 code, posx, posy, posx2, posy2;
+	uint16 code = 0, posx = 0, posy = 0, posx2 = 0, posy2 = 0;
 };
 
 struct CharacterAnim {
-	uint16 depth;
+	uint16 depth = 0;
 	byte *bitmap[4][kWalkFrameCount + 30]; // 30 = 3 actions * 10 frames each
 };
 
 struct SecondaryAnim {
-	uint16 depth, dir, posx, posy;
+	uint16 depth = 0, dir = 1, posx = 0, posy = 0;
 	byte *bitmap[4][kSecAnimationFrameCount];
 };
 




More information about the Scummvm-git-logs mailing list