[Scummvm-git-logs] scummvm master -> 346d4b08c4c0f86ff3c4e6241be2f9dfa7856830

rvanlaar noreply at scummvm.org
Sun Oct 16 20:06:34 UTC 2022


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:
346d4b08c4 DIRECTOR: FONTS: Fix memory leak


Commit: 346d4b08c4c0f86ff3c4e6241be2f9dfa7856830
    https://github.com/scummvm/scummvm/commit/346d4b08c4c0f86ff3c4e6241be2f9dfa7856830
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-10-16T22:06:27+02:00

Commit Message:
DIRECTOR: FONTS: Fix memory leak

Don't map the same fromFont twice.
CloneRanger mapped one fromFont twice, resulting in a memory leak on
descruction since the pointer to the first fontMap was lost.

Changed paths:
    engines/director/fonts.cpp


diff --git a/engines/director/fonts.cpp b/engines/director/fonts.cpp
index c399815674d..0ff4423b796 100644
--- a/engines/director/fonts.cpp
+++ b/engines/director/fonts.cpp
@@ -421,12 +421,18 @@ bool Cast::readFXmpLine(Common::SeekableReadStreamEndian &stream) {
 
 		// TODO: We should fill _fontXPlatformMap with mappings matching the current platform.
 		// We only have Mac fonts right now, though, so we'll always use the Win => Mac mappings.
+		// We only handle one fontmap per fromFont (happens in Clone Ranger)
 		if (fromPlatform == Common::kPlatformWindows) {
-			_fontXPlatformMap[fromFont] = info;
-			debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' to Mac font '%s'", fromFont.c_str(), info->toFont.c_str());
-			debugC(4, kDebugLoading, "  Remap characters: %d", info->remapChars);
-			for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
-				debugC(4, kDebugLoading, "  Mapping size %d to %d", it->_key, it->_value);
+			if (_fontXPlatformMap.contains(fromFont)) {
+				warning("Cast::readFxmpLine: Skip second map for font '%s'", fromFont.c_str());
+				delete info;
+			} else {
+				_fontXPlatformMap[fromFont] = info;
+				debugC(3, kDebugLoading, "Cast::readFXmpLine: Mapping Win font '%s' to Mac font '%s'", fromFont.c_str(), info->toFont.c_str());
+				debugC(4, kDebugLoading, "  Remap characters: %d", info->remapChars);
+				for (FontSizeMap::iterator it = info->sizeMap.begin(); it != info->sizeMap.end(); ++it) {
+					debugC(4, kDebugLoading, "  Mapping size %d to %d", it->_key, it->_value);
+				}
 			}
 		} else {
 			delete info;




More information about the Scummvm-git-logs mailing list