[Scummvm-git-logs] scummvm branch-2-8 -> d4df330a7d96ac6396aaaaf0e75e74827fcd1f9e

sluicebox noreply at scummvm.org
Fri Dec 8 03:43:52 UTC 2023


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

Summary:
62392f340c BACKENDS: Fix memory leak in DefaultAudioCDManager. PVS-Studio V773
a5ef00a514 COMMON: Fix StuffIt memory leak. PVS-Studio V773
5a014803f0 AGOS: Fix memory leak. PVS-Studio V773
358e04e4c3 BBVS: Fix memory leak. PVS-Studio V773
745ff895ea CRYOMNI3D: Fix memory leak. PVS-Studio V773
cd6870ddd1 DIRECTOR: Fix memory leaks. PVS-Studio V773
5a29a699cd GLK: SCOTT: Fix memory leaks. PVS-Studio V773
e826d590a8 GLK: Fix memory leaks. PVS-Studio V773
77310b1b69 GRIFFON: Fix memory leaks. PVS-Studio V773
9156d7c3a6 SLUDGE: Fix memory leaks on error. PVS-Studio V773
1528a8437f SWORD1: Fix memory leaks. PVS-Studio V773
d4df330a7d TOLTECS: Fix memory leak. PVS-Studio V773


Commit: 62392f340c9aac36c62f25e423bd339feccaec99
    https://github.com/scummvm/scummvm/commit/62392f340c9aac36c62f25e423bd339feccaec99
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:41:20-08:00

Commit Message:
BACKENDS: Fix memory leak in DefaultAudioCDManager. PVS-Studio V773

Changed paths:
    backends/audiocd/default/default-audiocd.cpp


diff --git a/backends/audiocd/default/default-audiocd.cpp b/backends/audiocd/default/default-audiocd.cpp
index 482abf3c7f1..3988eebd8b4 100644
--- a/backends/audiocd/default/default-audiocd.cpp
+++ b/backends/audiocd/default/default-audiocd.cpp
@@ -138,11 +138,11 @@ bool DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int du
 bool DefaultAudioCDManager::playAbsolute(int startFrame, int numLoops, int duration, bool onlyEmulate,
 		Audio::Mixer::SoundType soundType, const char *cuesheet) {
 
-	Common::File *cuefile = new Common::File();
-	if (!cuefile->open(cuesheet)) {
+	Common::File cuefile;
+	if (!cuefile.open(cuesheet)) {
 		return false;
 	}
-	Common::String cuestring = cuefile->readString(0, cuefile->size());
+	Common::String cuestring = cuefile.readString(0, cuefile.size());
 	Common::CueSheet cue(cuestring.c_str());
 
 	Common::CueSheet::CueTrack *track = cue.getTrackAtFrame(startFrame);


Commit: a5ef00a514466a4a7b74dacd719c1f46aecc0846
    https://github.com/scummvm/scummvm/commit/a5ef00a514466a4a7b74dacd719c1f46aecc0846
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:41:28-08:00

Commit Message:
COMMON: Fix StuffIt memory leak. PVS-Studio V773

Changed paths:
    common/compression/stuffit.cpp


diff --git a/common/compression/stuffit.cpp b/common/compression/stuffit.cpp
index 217f0397b1b..4d3449f38f6 100644
--- a/common/compression/stuffit.cpp
+++ b/common/compression/stuffit.cpp
@@ -975,7 +975,7 @@ static void SIT13_CreateTree(struct SIT13Data *s, Common::BitStream8LSB *bits, s
 bool StuffItArchive::decompress13(Common::SeekableReadStream *src, byte *dst, uint32 uncompressedSize) const {
 	Common::MemoryWriteStream out(dst, uncompressedSize);
 
-	Common::BitStream8LSB *bits = new Common::BitStream8LSB(src);
+	Common::BitStream8LSB bits(src);
 
 	uint32 i, j;
 
@@ -990,7 +990,7 @@ bool StuffItArchive::decompress13(Common::SeekableReadStream *src, byte *dst, ui
 		s->Buffer4[i].freq = -1;
 	}
 
-	j = bits->getBits<8>();
+	j = bits.getBits<8>();
 	i = j>>4;
 	if(i > 5)
 		return false;
@@ -1003,15 +1003,15 @@ bool StuffItArchive::decompress13(Common::SeekableReadStream *src, byte *dst, ui
 	}
 	else
 	{
-		SIT13_CreateTree(s, bits, s->Buffer3, 0x141);
+		SIT13_CreateTree(s, &bits, s->Buffer3, 0x141);
 		if(j&8)
 			memcpy(s->Buffer3b, s->Buffer3, 0x1000*sizeof(struct SIT13Buffer));
 		else
-			SIT13_CreateTree(s, bits, s->Buffer3b, 0x141);
+			SIT13_CreateTree(s, &bits, s->Buffer3b, 0x141);
 		j = (j&7)+10;
-		SIT13_CreateTree(s, bits, s->Buffer2, j);
+		SIT13_CreateTree(s, &bits, s->Buffer2, j);
 	}
-	return SIT13_Extract(s, bits, out);
+	return SIT13_Extract(s, &bits, out);
 }
 
 #define OUTPUT_VAL(x) \


Commit: 5a014803f057e4abb3eb7ffa7442428dd136cbe2
    https://github.com/scummvm/scummvm/commit/5a014803f057e4abb3eb7ffa7442428dd136cbe2
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:41:34-08:00

Commit Message:
AGOS: Fix memory leak. PVS-Studio V773

Changed paths:
    engines/agos/event.cpp


diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp
index d83bf7794fb..e8595eb8041 100644
--- a/engines/agos/event.cpp
+++ b/engines/agos/event.cpp
@@ -477,9 +477,8 @@ void AGOSEngine::delay(uint amount) {
 					}
 				} else if (event.kbd.hasFlags(Common::KBD_CTRL)) {
 					if (event.kbd.keycode == Common::KEYCODE_a) {
-						GUI::Dialog *_aboutDialog;
-						_aboutDialog = new GUI::AboutDialog();
-						_aboutDialog->runModal();
+						GUI::AboutDialog aboutDialog;
+						aboutDialog.runModal();
 					} else if (event.kbd.keycode == Common::KEYCODE_f) {
 						_fastMode = !_fastMode;
 					}


Commit: 358e04e4c32d89dd224f0e9dbe17880ffb32015c
    https://github.com/scummvm/scummvm/commit/358e04e4c32d89dd224f0e9dbe17880ffb32015c
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:41:41-08:00

Commit Message:
BBVS: Fix memory leak. PVS-Studio V773

Changed paths:
    engines/bbvs/videoplayer.cpp


diff --git a/engines/bbvs/videoplayer.cpp b/engines/bbvs/videoplayer.cpp
index 595d32f13de..908f4788abf 100644
--- a/engines/bbvs/videoplayer.cpp
+++ b/engines/bbvs/videoplayer.cpp
@@ -35,9 +35,8 @@ void BbvsEngine::playVideo(int videoNum) {
 	else
 		videoFilename = Common::String::format("vid/video%03d.avi", videoNum - 1);
 
-	Video::VideoDecoder *videoDecoder = new Video::AVIDecoder();
-	if (!videoDecoder->loadFile(videoFilename)) {
-		delete videoDecoder;
+	Video::AVIDecoder videoDecoder;
+	if (!videoDecoder.loadFile(videoFilename)) {
 		warning("Unable to open video %s", videoFilename.c_str());
 		return;
 	}
@@ -51,13 +50,13 @@ void BbvsEngine::playVideo(int videoNum) {
 
 	debug(0, "Screen format: %s", _system->getScreenFormat().toString().c_str());
 
-	videoDecoder->start();
+	videoDecoder.start();
 
 	bool skipVideo = false;
 
-	while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
-		if (videoDecoder->needsUpdate()) {
-			const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
+	while (!shouldQuit() && !videoDecoder.endOfVideo() && !skipVideo) {
+		if (videoDecoder.needsUpdate()) {
+			const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
 			if (frame) {
 				if (frame->format.bytesPerPixel > 1) {
 					Graphics::Surface *frame1 = frame->convertTo(_system->getScreenFormat());
@@ -81,8 +80,6 @@ void BbvsEngine::playVideo(int videoNum) {
 		_system->delayMillis(10);
 	}
 
-	delete videoDecoder;
-
 	initGraphics(320, 240);
 
 }


Commit: 745ff895ea10a1e4f7048aec05ad986ba741f4f5
    https://github.com/scummvm/scummvm/commit/745ff895ea10a1e4f7048aec05ad986ba741f4f5
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:41:48-08:00

Commit Message:
CRYOMNI3D: Fix memory leak. PVS-Studio V773

Changed paths:
    engines/cryomni3d/versailles/dialogs_manager.cpp


diff --git a/engines/cryomni3d/versailles/dialogs_manager.cpp b/engines/cryomni3d/versailles/dialogs_manager.cpp
index 4d9393196db..d4cbac70498 100644
--- a/engines/cryomni3d/versailles/dialogs_manager.cpp
+++ b/engines/cryomni3d/versailles/dialogs_manager.cpp
@@ -354,21 +354,20 @@ uint Versailles_DialogsManager::askPlayerQuestions(const Common::String &video,
 void Versailles_DialogsManager::loadFrame(const Common::String &video) {
 	Common::Path videoPath(_engine->getFilePath(kFileTypeDialAnim, video));
 
-	Video::HNMDecoder *videoDecoder = new Video::HNMDecoder(g_system->getScreenFormat());
+	Video::HNMDecoder videoDecoder(g_system->getScreenFormat());
 
-	if (!videoDecoder->loadFile(videoPath)) {
+	if (!videoDecoder.loadFile(videoPath)) {
 		warning("Failed to open movie file %s/%s", video.c_str(), videoPath.toString().c_str());
-		delete videoDecoder;
 		return;
 	}
 
 	// Preload first frame to draw questions on it
-	const Graphics::Surface *firstFrame = videoDecoder->decodeNextFrame();
+	const Graphics::Surface *firstFrame = videoDecoder.decodeNextFrame();
 	_lastImage.create(firstFrame->w, firstFrame->h, firstFrame->format);
 	_lastImage.blitFrom(*firstFrame);
 
-	if (videoDecoder->hasDirtyPalette()) {
-		const byte *palette = videoDecoder->getPalette();
+	if (videoDecoder.hasDirtyPalette()) {
+		const byte *palette = videoDecoder.getPalette();
 		_engine->setupPalette(palette, 0, 256);
 	}
 }


Commit: cd6870ddd15ad6005ab4907fbe5205d62a41b9d7
    https://github.com/scummvm/scummvm/commit/cd6870ddd15ad6005ab4907fbe5205d62a41b9d7
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:01-08:00

Commit Message:
DIRECTOR: Fix memory leaks. PVS-Studio V773

Changed paths:
    engines/director/lingo/xlibs/applecdxobj.cpp
    engines/director/sound.cpp


diff --git a/engines/director/lingo/xlibs/applecdxobj.cpp b/engines/director/lingo/xlibs/applecdxobj.cpp
index beb4f227ec1..1891a2fff2e 100644
--- a/engines/director/lingo/xlibs/applecdxobj.cpp
+++ b/engines/director/lingo/xlibs/applecdxobj.cpp
@@ -145,9 +145,9 @@ AppleCDXObject::AppleCDXObject(ObjectType ObjectType) :Object<AppleCDXObject>("A
 	_outpoint = 0;
 	_cue = nullptr;
 
-	Common::File *cuefile = new Common::File();
-	if (cuefile->open("disc.cue")) {
-		Common::String cuestring = cuefile->readString(0, cuefile->size());
+	Common::File cuefile;
+	if (cuefile.open("disc.cue")) {
+		Common::String cuestring = cuefile.readString(0, cuefile.size());
 
 		_cue = new Common::CueSheet(cuestring.c_str());
 	}
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 7534ceac630..3c15fc3d59e 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -596,8 +596,8 @@ void DirectorSound::playFPlaySound() {
 
 	Common::SeekableReadStreamEndian *sndData = archive->getResource(tag, id);
 	if (sndData != nullptr) {
-		SNDDecoder *ad = new SNDDecoder();
-		ad->loadStream(*sndData);
+		SNDDecoder ad;
+		ad.loadStream(*sndData);
 		delete sndData;
 
 		Audio::AudioStream *as;
@@ -610,7 +610,7 @@ void DirectorSound::playFPlaySound() {
 
 		// FPlay is controlled by Lingo, not the score, like a puppet,
 		// so we'll get the puppet version of the stream.
-		as = ad->getAudioStream(looping, true);
+		as = ad.getAudioStream(looping, true);
 
 		if (!as) {
 			warning("DirectorSound:playFPlaySound: failed to get audio stream");
@@ -621,7 +621,6 @@ void DirectorSound::playFPlaySound() {
 		_currentSoundName = sndName;
 
 		playStream(*as, 1);
-		delete ad;
 	}
 
 	// Set the last played sound so that cast member 0 in the sound channel doesn't stop this file.


Commit: 5a29a699cd6ed59a212cc4ff9749cf2392b4e697
    https://github.com/scummvm/scummvm/commit/5a29a699cd6ed59a212cc4ff9749cf2392b4e697
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:08-08:00

Commit Message:
GLK: SCOTT: Fix memory leaks. PVS-Studio V773

Changed paths:
    engines/glk/scott/c64_checksums.cpp
    engines/glk/scott/load_ti99_4a.cpp


diff --git a/engines/glk/scott/c64_checksums.cpp b/engines/glk/scott/c64_checksums.cpp
index a9ebe2ecba8..4471eeb71bb 100644
--- a/engines/glk/scott/c64_checksums.cpp
+++ b/engines/glk/scott/c64_checksums.cpp
@@ -258,6 +258,7 @@ void appendSIfiles(uint8_t **sf, size_t *extent) {
 	*extent = offset + _G(_saveIslandAppendix1Length) + _G(_saveIslandAppendix2Length);
 	*sf = new uint8_t[*extent];
 	memcpy(*sf, megabuf, *extent);
+	delete[] megabuf;
 }
 
 int mysteriousMenu(uint8_t **sf, size_t *extent, int recindex) {
@@ -424,11 +425,13 @@ int detectC64(uint8_t **sf, size_t *extent) {
 			memcpy(megabuf + newlength + g_C64Registry[index]._parameter, appendix + 2, appendixlen);
 			newlength += appendixlen;
 		}
+		delete[] appendix;
 
 		if (largest_file) {
 			*sf = megabuf;
 			*extent = newlength;
 		}
+		delete[] largest_file;
 
 	} else if (g_C64Registry[index]._type == TYPE_T64) {
 		uint8_t *file_records = *sf + 64;
diff --git a/engines/glk/scott/load_ti99_4a.cpp b/engines/glk/scott/load_ti99_4a.cpp
index 7dddd36c957..957b655009b 100644
--- a/engines/glk/scott/load_ti99_4a.cpp
+++ b/engines/glk/scott/load_ti99_4a.cpp
@@ -441,10 +441,11 @@ int tryLoadingTI994A(DataHeader dh, int loud) {
 	ct = 0;
 	ip = &_G(_items)[0];
 
-	int *objectlinks = new int[ni + 1];
-
-	if (seekIfNeeded(fixAddress(fixWord(dh._pObjLink)), &offset, &ptr) == 0)
+	if (seekIfNeeded(fixAddress(fixWord(dh._pObjLink)), &offset, &ptr) == 0) {
 		return 0;
+	}
+
+	int *objectlinks = new int[ni + 1];
 
 	do {
 		objectlinks[ct] = *(ptr++ - _G(_fileBaselineOffset));
@@ -459,6 +460,8 @@ int tryLoadingTI994A(DataHeader dh, int loud) {
 		ip++;
 	} while (ct < ni + 1);
 
+	delete[] objectlinks;
+
 	readTI99ImplicitActions(dh);
 	readTI99ExplicitActions(dh);
 


Commit: e826d590a8c772347d263f8542ec4f2e7701895e
    https://github.com/scummvm/scummvm/commit/e826d590a8c772347d263f8542ec4f2e7701895e
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:17-08:00

Commit Message:
GLK: Fix memory leaks. PVS-Studio V773

Changed paths:
    engines/glk/streams.cpp


diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp
index d84ae4e8b14..ef39a97bce9 100644
--- a/engines/glk/streams.cpp
+++ b/engines/glk/streams.cpp
@@ -1429,18 +1429,18 @@ frefid_t Streams::createByPrompt(uint usage, FileMode fmode, uint rock) {
 	case fileusage_SavedGame: {
 		if (fmode == filemode_Write) {
 			// Select a savegame slot
-			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+			GUI::SaveLoadChooser dialog(_("Save game:"), _("Save"), true);
 
-			int slot = dialog->runModalWithCurrentTarget();
+			int slot = dialog.runModalWithCurrentTarget();
 			if (slot >= 0) {
-				Common::String desc = dialog->getResultString();
+				Common::String desc = dialog.getResultString();
 				return createRef(slot, desc, usage, rock);
 			}
 		} else if (fmode == filemode_Read) {
 			// Load a savegame slot
-			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+			GUI::SaveLoadChooser dialog(_("Restore game:"), _("Restore"), false);
 
-			int slot = dialog->runModalWithCurrentTarget();
+			int slot = dialog.runModalWithCurrentTarget();
 			if (slot >= 0) {
 				return createRef(slot, "", usage, rock);
 			}


Commit: 77310b1b696c52441c84e770719142b2b99fec27
    https://github.com/scummvm/scummvm/commit/77310b1b696c52441c84e770719142b2b99fec27
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:24-08:00

Commit Message:
GRIFFON: Fix memory leaks. PVS-Studio V773

Changed paths:
    engines/griffon/resources.cpp


diff --git a/engines/griffon/resources.cpp b/engines/griffon/resources.cpp
index fb41ba76be6..ffb9512c7a9 100644
--- a/engines/griffon/resources.cpp
+++ b/engines/griffon/resources.cpp
@@ -1101,7 +1101,7 @@ void GriffonEngine::loadItemImgs() {
 		temp->blendBlitTo(*_itemImg[i], 0, 0, Graphics::FLIP_NONE, &rcSrc);
 	}
 
-	temp->free();
+	delete temp;
 }
 
 void GriffonEngine::loadFont() {
@@ -1128,7 +1128,7 @@ void GriffonEngine::loadFont() {
 			font->blendBlitTo(*_fontChr[i2][f], rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
 		}
 
-	font->free();
+	delete font;
 }
 
 void GriffonEngine::loadTiles() {


Commit: 9156d7c3a6e7789dea2eeca49da6e406c414991a
    https://github.com/scummvm/scummvm/commit/9156d7c3a6e7789dea2eeca49da6e406c414991a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:32-08:00

Commit Message:
SLUDGE: Fix memory leaks on error. PVS-Studio V773

Changed paths:
    engines/sludge/builtin.cpp
    engines/sludge/floor.cpp


diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 00bd7a13519..4faacf3e9ef 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -824,8 +824,10 @@ builtIn(anim) {
 
 	// Only remaining parameter is the file number
 	int fileNumber;
-	if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE))
+	if (!fun->stack->thisVar.getValueType(fileNumber, SVT_FILE)) {
+		delete ba;
 		return BR_ERROR;
+	}
 	trimStack(fun->stack);
 
 	// Load the required sprite bank
diff --git a/engines/sludge/floor.cpp b/engines/sludge/floor.cpp
index b2636ff341d..075d11d6982 100644
--- a/engines/sludge/floor.cpp
+++ b/engines/sludge/floor.cpp
@@ -184,11 +184,13 @@ bool FloorManager::setFloor(int fileNum) {
 	// Now build the movement martix
 
 	_currentFloor->matrix = new int *[_currentFloor->numPolygons];
-	int **distanceMatrix = new int *[_currentFloor->numPolygons];
-
 	if (!checkNew(_currentFloor->matrix))
 		return false;
 
+	int **distanceMatrix = new int *[_currentFloor->numPolygons];
+	if (!checkNew(distanceMatrix))
+		return false;
+
 	for (i = 0; i < _currentFloor->numPolygons; i++) {
 		_currentFloor->matrix[i] = new int[_currentFloor->numPolygons];
 		distanceMatrix[i] = new int[_currentFloor->numPolygons];


Commit: 1528a8437f182c71566f4939a5f473d171634ea8
    https://github.com/scummvm/scummvm/commit/1528a8437f182c71566f4939a5f473d171634ea8
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:38-08:00

Commit Message:
SWORD1: Fix memory leaks. PVS-Studio V773

Changed paths:
    engines/sword1/resman.cpp


diff --git a/engines/sword1/resman.cpp b/engines/sword1/resman.cpp
index 2b6b27a59eb..b2aa6712651 100644
--- a/engines/sword1/resman.cpp
+++ b/engines/sword1/resman.cpp
@@ -142,18 +142,17 @@ void ResMan::loadCluDescript(const char *fileName) {
 			_srIdList[cnt] = 0x04050000 | cnt;
 
 	if (_isKorTrs) {
-		Common::File *cluFile = new Common::File();
-		cluFile->open("korean.clu");
-		if (cluFile->isOpen()) {
+		Common::File cluFile;
+		cluFile.open("korean.clu");
+		if (cluFile.isOpen()) {
 			for (uint32 resCnt = 0, resOffset = 0; resCnt < _prj.clu[2].grp[0].noRes; resCnt++) {
 				Header header;
-				cluFile->read(&header, sizeof(Header));
+				cluFile.read(&header, sizeof(Header));
 				_prj.clu[2].grp[0].offset[resCnt] = resOffset;
 				_prj.clu[2].grp[0].length[resCnt] = header.comp_length;
 				resOffset += header.comp_length;
-				cluFile->seek(header.decomp_length, SEEK_CUR);
+				cluFile.seek(header.decomp_length, SEEK_CUR);
 			}
-			cluFile->close();
 			Common::strcpy_s(_prj.clu[2].label, "korean");
 		} else {
 			_isKorTrs = false;
@@ -279,12 +278,11 @@ void ResMan::resOpen(uint32 id) {  // load resource ID into memory
 			// Load Korean Font
 			uint32 size = resLength(id);
 			uint32 korFontSize = 0;
-			Common::File *korFontFile = NULL;
+			Common::File korFontFile;
 
-			korFontFile = new Common::File();
-			korFontFile->open("bs1k.fnt");
-			if (korFontFile->isOpen()) {
-				korFontSize = korFontFile->size();
+			korFontFile.open("bs1k.fnt");
+			if (korFontFile.isOpen()) {
+				korFontSize = korFontFile.size();
 			}
 			_memMan->alloc(memHandle, size + korFontSize);
 			Common::File *clusFile = resFile(id);
@@ -296,8 +294,7 @@ void ResMan::resOpen(uint32 id) {  // load resource ID into memory
 			}
 
 			if (korFontSize > 0) {
-				korFontFile->read((uint8 *)memHandle->data + size, korFontSize);
-				korFontFile->close();
+				korFontFile.read((uint8 *)memHandle->data + size, korFontSize);
 			}
 		} else {
 			uint32 size = resLength(id);


Commit: d4df330a7d96ac6396aaaaf0e75e74827fcd1f9e
    https://github.com/scummvm/scummvm/commit/d4df330a7d96ac6396aaaaf0e75e74827fcd1f9e
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-07T19:42:44-08:00

Commit Message:
TOLTECS: Fix memory leak. PVS-Studio V773

Changed paths:
    engines/toltecs/menu.cpp


diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp
index ca131ac9ce2..96f120f5eb7 100644
--- a/engines/toltecs/menu.cpp
+++ b/engines/toltecs/menu.cpp
@@ -299,12 +299,12 @@ void MenuSystem::initMenu(MenuID menuID) {
 			_savegames.push_back(SavegameItem(newSlotNum, Common::String::format("GAME %04d", _savegames.size())));
 			setSavegameCaptions(true);
 		} else {
-			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
-			int slot = dialog->runModalWithCurrentTarget();
-			Common::String desc = dialog->getResultString();
+			GUI::SaveLoadChooser dialog(_("Save game:"), _("Save"), true);
+			int slot = dialog.runModalWithCurrentTarget();
+			Common::String desc = dialog.getResultString();
 			if (desc.empty()) {
 				// Create our own description for the saved game, the user didn't enter one
-				desc = dialog->createDefaultSaveDescription(slot);
+				desc = dialog.createDefaultSaveDescription(slot);
 			}
 
 			if (slot >= 0) {




More information about the Scummvm-git-logs mailing list