[Scummvm-git-logs] scummvm master -> 1c629d4c0d444be1552adfc8cf0fa55b8d45e306

athrxx noreply at scummvm.org
Sun Nov 17 17:58:12 UTC 2024


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:
1c629d4c0d SCUMM: fix invalid mem access (bug no. 15507)


Commit: 1c629d4c0d444be1552adfc8cf0fa55b8d45e306
    https://github.com/scummvm/scummvm/commit/1c629d4c0d444be1552adfc8cf0fa55b8d45e306
Author: athrxx (athrxx at scummvm.org)
Date: 2024-11-17T18:57:03+01:00

Commit Message:
SCUMM: fix invalid mem access (bug no. 15507)

Changed paths:
    engines/scumm/string.cpp
    engines/scumm/string_v7.cpp


diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index c3ec348aab4..b7edea54a92 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -450,7 +450,8 @@ bool ScummEngine::handleNextCharsetCode(Actor *a, int *code) {
 			oldy = _charset->getFontHeight();
 			_charset->setCurID(*buffer++);
 			buffer += 2;
-			memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
+			if (_charset->getCurID() != -1)
+				memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
 			_nextTop -= _charset->getFontHeight() - oldy;
 			break;
 		default:
@@ -1016,7 +1017,7 @@ void ScummEngine::displayDialog() {
 	else
 		_charset->setCurID(_string[0].charset);
 
-	if (_game.version >= 5)
+	if (_game.version >= 5 && _charset->getCurID() != -1)
 		memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], 4);
 
 #ifndef DISABLE_TOWNS_DUAL_LAYER_MODE
@@ -1236,7 +1237,7 @@ void ScummEngine::drawString(int a, const byte *msg) {
 	VirtScreen *vs = findVirtScreen(_charset->_top);
 	bool shadowModeFlag = (vs && vs->number == kMainVirtScreen);
 
-	if (_game.version >= 5)
+	if (_game.version >= 5 && _charset->getCurID() != -1)
 		memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], _game.id == GID_DIG ? sizeof(_charsetColorMap) : 4);
 
 	fontHeight = _charset->getFontHeight();
diff --git a/engines/scumm/string_v7.cpp b/engines/scumm/string_v7.cpp
index e463d4fbb13..6b6ac4199f0 100644
--- a/engines/scumm/string_v7.cpp
+++ b/engines/scumm/string_v7.cpp
@@ -466,7 +466,7 @@ void ScummEngine_v7::drawBlastTexts() {
 
 		_charset->setCurID(_blastTextQueue[i].charset);
 
-		if (_game.version == 7)
+		if (_game.version == 7 && _charset->getCurID() != -1)
 			memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], _game.id == GID_DIG ? sizeof(_charsetColorMap) : 4);
 
 		if (bt.flags & kStyleWordWrap) {
@@ -653,7 +653,7 @@ void ScummEngine_v7::displayDialog() {
 		_charset->_center = _string[0].center;
 	}
 
-	if (_game.version == 7)
+	if (_game.version == 7 && _charset->getCurID() != -1)
 		memcpy(_charsetColorMap, _charsetData[_charset->getCurID()], _game.id == GID_DIG ? sizeof(_charsetColorMap) : 4);
 
 	if (usingOldSystem && a && a->_charset) {




More information about the Scummvm-git-logs mailing list