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

sev- noreply at scummvm.org
Sun Oct 15 00:29:12 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:
c57bc10806 GRAPHICS: MACGUI: Fix crash when adding newline in MacText


Commit: c57bc10806876d48429cc957daaef0a5963992c2
    https://github.com/scummvm/scummvm/commit/c57bc10806876d48429cc957daaef0a5963992c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-10-14T17:29:02-07:00

Commit Message:
GRAPHICS: MACGUI: Fix crash when adding newline in MacText

The behaviour is now badly broken, but at least it will not crash

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 40773d4ac5c..0fc7f95e502 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -701,7 +701,7 @@ void MacText::chopChunk(const Common::U32String &str, int *curLinePtr, int inden
 void MacText::splitString(const Common::U32String &str, int curLine) {
 	const Common::U32String::value_type *l = str.c_str();
 
-	D(9, "** splitString(\"%s\")", toPrintable(str.encode()).c_str());
+	D(9, "** splitString(\"%s\", %d)", toPrintable(str.encode()).c_str(), curLine);
 
 	if (_canvas._text.empty()) {
 		_canvas._text.resize(1);
@@ -718,7 +718,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
 
 	Common::U32String paragraph, tmp;
 
-	if (curLine == -1)
+	if (curLine == -1 || curLine >= _canvas._text.size())
 		curLine = _canvas._text.size() - 1;
 
 	int curChunk = _canvas._text[curLine].chunks.size() - 1;




More information about the Scummvm-git-logs mailing list