[Scummvm-git-logs] scummvm master -> 7c08a70ec9c30b0a7ce8579403db9b3853cabdd3

kelmer44 noreply at scummvm.org
Wed Oct 8 04:15:26 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:
7c08a70ec9 TOT: Initializes arrays with new. PVS-Studio: V522


Commit: 7c08a70ec9c30b0a7ce8579403db9b3853cabdd3
    https://github.com/scummvm/scummvm/commit/7c08a70ec9c30b0a7ce8579403db9b3853cabdd3
Author: kelmer (kelmer at gmail.com)
Date: 2025-10-08T06:15:12+02:00

Commit Message:
TOT: Initializes arrays with new. PVS-Studio: V522

Changed paths:
    engines/tot/anims.cpp
    engines/tot/engine.cpp
    engines/tot/forest.cpp
    engines/tot/tot.cpp


diff --git a/engines/tot/anims.cpp b/engines/tot/anims.cpp
index 8566cbb07c0..195fb2342fb 100644
--- a/engines/tot/anims.cpp
+++ b/engines/tot/anims.cpp
@@ -917,7 +917,7 @@ void drawFlc(
 						if (flic->hasDirtyPalette()) {
 
 							const byte *fliPalette = (const byte *)flic->getPalette();
-							byte *palette = (byte *)malloc(768);
+							byte *palette = new byte[768];
 							Common::copy(fliPalette, fliPalette + 768, palette);
 							// game fixes background to 0
 							palette[0] = 0;
@@ -943,7 +943,7 @@ void drawFlc(
 								g_engine->_graphics->setPalette(palette);
 								g_engine->_graphics->copyPalette(palette, g_engine->_graphics->_pal);
 							}
-							free(palette);
+							delete[] palette;
 						}
 						g_engine->_chrono->_gameTick = false;
 					} else {
diff --git a/engines/tot/engine.cpp b/engines/tot/engine.cpp
index 4783f291e68..4ba73c54a80 100644
--- a/engines/tot/engine.cpp
+++ b/engines/tot/engine.cpp
@@ -4547,7 +4547,7 @@ static void loadDiploma(Common::String &photoName, Common::String &key) {
 	g_engine->_screen->markAllDirty();
 	g_engine->_screen->update();
 
-	char *passArray = (char *)malloc(10);
+	char *passArray =  new char[10];
 	for (int i = 0; i < 10; i++)
 		passArray[i] = (char)(getRandom(10) + 48);
 
@@ -4582,7 +4582,7 @@ static void loadDiploma(Common::String &photoName, Common::String &key) {
 	delay(1500);
 	g_engine->_sound->playVoc("PORTAZO", 434988, 932);
 	g_engine->_graphics->putShape(270, 159, stamp);
-	free(passArray);
+	delete[] passArray;
 	free(stamp);
 }
 
diff --git a/engines/tot/forest.cpp b/engines/tot/forest.cpp
index 7bbba29cd74..691cea2ab57 100644
--- a/engines/tot/forest.cpp
+++ b/engines/tot/forest.cpp
@@ -108,13 +108,11 @@ void saveExpression(Common::SeekableWriteStream *s, Common::String expression) {
 	int paddingSize = 255 - expression.size();
 	if (paddingSize > 0) {
 		debug("Writing padding of %d", paddingSize);
-		char *padding = (char *)malloc(paddingSize);
-		for (int i = 0; i < paddingSize; i++) {
-			padding[i] = '\0';
-		}
+		char *padding = new char[paddingSize];
+		memset(padding, '\0', paddingSize);
 		// 8 max char name
 		s->write(padding, paddingSize);
-		free(padding);
+		delete[] padding;
 	}
 }
 
diff --git a/engines/tot/tot.cpp b/engines/tot/tot.cpp
index 8b5b3e90d07..6017e050aa8 100644
--- a/engines/tot/tot.cpp
+++ b/engines/tot/tot.cpp
@@ -1312,6 +1312,9 @@ void TotEngine::exitToDOS() {
 		}
 		_screen->update();
 	} while (exitChar != '\33' && !shouldQuit());
+	if (shouldQuit()) {
+		return;
+	}
 	_graphics->putImg(58, 48, dialogBackground);
 	_mouse->mouseX = oldMousePosX;
 	_mouse->mouseY = oldMousePosY;




More information about the Scummvm-git-logs mailing list