[Scummvm-git-logs] scummvm master -> acf642066c81418e9adfede9518aa4d5754d6341

sluicebox noreply at scummvm.org
Tue Dec 19 02:14:02 UTC 2023


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

Summary:
acf642066c SWORD2: Fix memory leak when loading Korean font. PVS-Studio V773


Commit: acf642066c81418e9adfede9518aa4d5754d6341
    https://github.com/scummvm/scummvm/commit/acf642066c81418e9adfede9518aa4d5754d6341
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-12-18T18:12:59-08:00

Commit Message:
SWORD2: Fix memory leak when loading Korean font. PVS-Studio V773

Changed paths:
    engines/sword2/resman.cpp


diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp
index cc803640aad..a290e756b33 100644
--- a/engines/sword2/resman.cpp
+++ b/engines/sword2/resman.cpp
@@ -314,12 +314,10 @@ byte *ResourceManager::openResource(uint32 res, bool dump) {
 		if (res == ENGLISH_SPEECH_FONT_ID && _vm->_isKorTrs) {
 			// Load Korean Font
 			uint32 korFontSize = 0;
-			Common::File *korFontFile = nullptr;
-
-			korFontFile = new Common::File();
-			korFontFile->open("bs2k.fnt");
-			if (korFontFile->isOpen()) {
-				korFontSize = korFontFile->size();
+			Common::File korFontFile;
+			korFontFile.open("bs2k.fnt");
+			if (korFontFile.isOpen()) {
+				korFontSize = korFontFile.size();
 			}
 
 			// Ok, we know the length so try and allocate the memory.
@@ -330,8 +328,7 @@ byte *ResourceManager::openResource(uint32 res, bool dump) {
 			file->read(_resList[res].ptr, len);
 
 			if (korFontSize > 0) {
-				korFontFile->read(_resList[res].ptr + len, korFontSize);
-				korFontFile->close();
+				korFontFile.read(_resList[res].ptr + len, korFontSize);
 			}
 
 			len += korFontSize;




More information about the Scummvm-git-logs mailing list