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

sev- sev at scummvm.org
Fri Apr 3 21:33:50 UTC 2020


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

Summary:
edb2edf3f4 DIRECTOR: Fix memory leaks
d39e86723e DIRECTOR: Initialize class variable
d668f31726 DIRECTOR: Fix potential null dereference
6e351796d4 DIRECTOR: Fix potential buffer override
e4e5719929 DIRECTOR: Sanity check
a1cf5bf0ee DIRECTOR: Use reserve() instead of resize() for Arrays
373d795c83 DIRECTOR: Initialize Symbol structure
9ea0b3198e DIRECTOR: Fix potential null pointer dereferences
0b7f54a893 DIRECTOR: Add sanity check to Lnam reading
38bd50abb4 DIRECTOR: Fix memory overlap
af9d122b0d DIRECTOR: Initialize Stxt


Commit: edb2edf3f4d1c062d9dc391a83f10cf71f7e4f85
    https://github.com/scummvm/scummvm/commit/edb2edf3f4d1c062d9dc391a83f10cf71f7e4f85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Fix memory leaks

Changed paths:
    engines/director/lingo/lingo-funcs.cpp
    engines/director/sound.cpp


diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index 7a75923e2f..be1e5909da 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -399,6 +399,8 @@ void Lingo::func_cursor(int c, int m) {
 		warning("STUB: func_cursor(): Hotspot is the registration point of the cast member");
 		_vm->getMacWindowManager()->pushCustomCursor(assembly, 16, 16, 1, 1, 3);
 
+		free(assembly);
+
 		return;
 	}
 
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 009b69b15a..79fb1ded34 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -88,13 +88,14 @@ void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
 }
 
 void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
-	Common::File *file = new Common::File();
-
 	if (soundChannel == 0 || soundChannel > _channels.size()) {
 		warning("Invalid sound channel %d", soundChannel);
+
 		return;
 	}
 
+	Common::File *file = new Common::File();
+
 	if (!file->open(filename)) {
 		warning("Failed to open %s", filename.c_str());
 
@@ -110,13 +111,13 @@ void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
 }
 
 void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) {
-	Common::File *file = new Common::File();
-
 	if (soundChannel == 0 || soundChannel > _channels.size()) {
 		warning("Invalid sound channel %d", soundChannel);
 		return;
 	}
 
+	Common::File *file = new Common::File();
+
 	if (!file->open(filename)) {
 		warning("Failed to open %s", filename.c_str());
 		delete file;


Commit: d39e86723ec20f1057abfafa90311c0064ffc2b2
    https://github.com/scummvm/scummvm/commit/d39e86723ec20f1057abfafa90311c0064ffc2b2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Initialize class variable

Changed paths:
    engines/director/cachedmactext.cpp
    engines/director/score.cpp


diff --git a/engines/director/cachedmactext.cpp b/engines/director/cachedmactext.cpp
index 6c0b47fb88..4d690f828e 100644
--- a/engines/director/cachedmactext.cpp
+++ b/engines/director/cachedmactext.cpp
@@ -64,7 +64,7 @@ CachedMacText::~CachedMacText() {
 CachedMacText::CachedMacText(TextCast *const textCast, int32 bgcolor, int version, int defaultWidth,
 								Graphics::MacWindowManager *const wm) :
 		_surface(NULL), _macText(NULL), _width(defaultWidth), _dirty(true),
-		_textCast(textCast), _wm(wm), _bgcolor(bgcolor) {
+		_textCast(textCast), _wm(wm), _bgcolor(bgcolor), _align(Graphics::kTextAlignLeft) {
 
 	debugC(5, kDebugText, "CachedMacText::CachedMacText(): font id: %d '%s'", _textCast->_fontId, Common::toPrintable(_textCast->_ftext).c_str());
 
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 19de8c8fba..1463fe2875 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -328,7 +328,7 @@ void Score::loadSpriteImages(bool isSharedCast) {
 		BitmapCast *bitmapCast = (BitmapCast *)c->_value;
 		uint32 tag = bitmapCast->_tag;
 		uint16 imgId = c->_key;
-		uint16 realId;
+		uint16 realId = 0;
 
 		Image::ImageDecoder *img = NULL;
 		Common::SeekableReadStream *pic = NULL;
@@ -387,6 +387,9 @@ void Score::loadSpriteImages(bool isSharedCast) {
 			break;
 		}
 
+		if (!img)
+			continue;
+
 		img->loadStream(*pic);
 
 		delete pic;


Commit: d668f317265c25f40956cc69028224f84c33264e
    https://github.com/scummvm/scummvm/commit/d668f317265c25f40956cc69028224f84c33264e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Fix potential null dereference

Changed paths:
    engines/director/director.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 822760a74d..30ed82dd22 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -228,25 +228,25 @@ Common::Error DirectorEngine::run() {
 			debug(0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
 
 			_currentScore->loadArchive();
-		}
 
-		// If we came in a loop, then skip as requested
-		if (!_nextMovie.frameS.empty()) {
-			_currentScore->setStartToLabel(_nextMovie.frameS);
-			_nextMovie.frameS.clear();
-		}
+			// If we came in a loop, then skip as requested
+			if (!_nextMovie.frameS.empty()) {
+				_currentScore->setStartToLabel(_nextMovie.frameS);
+				_nextMovie.frameS.clear();
+			}
 
-		if (_nextMovie.frameI != -1) {
-			_currentScore->setCurrentFrame(_nextMovie.frameI);
-			_nextMovie.frameI = -1;
-		}
+			if (_nextMovie.frameI != -1) {
+				_currentScore->setCurrentFrame(_nextMovie.frameI);
+				_nextMovie.frameI = -1;
+			}
 
-		if (!debugChannelSet(-1, kDebugLingoCompileOnly) && _currentScore) {
-			debugC(1, kDebugEvents, "Starting playback of score '%s'", _currentScore->getMacName().c_str());
+			if (!debugChannelSet(-1, kDebugLingoCompileOnly)) {
+				debugC(1, kDebugEvents, "Starting playback of score '%s'", _currentScore->getMacName().c_str());
 
-			_currentScore->startLoop();
+				_currentScore->startLoop();
 
-			debugC(1, kDebugEvents, "Finished playback of score '%s'", _currentScore->getMacName().c_str());
+				debugC(1, kDebugEvents, "Finished playback of score '%s'", _currentScore->getMacName().c_str());
+			}
 		}
 
 		if (getGameID() == GID_TESTALL) {


Commit: 6e351796d47cef71f85d7fb53198ff2df4371094
    https://github.com/scummvm/scummvm/commit/6e351796d47cef71f85d7fb53198ff2df4371094
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Fix potential buffer override

Changed paths:
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index ba9c16bfbb..d4da8e3605 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -102,7 +102,7 @@ Lingo::~Lingo() {
 }
 
 ScriptContext *Lingo::getScriptContext(ScriptType type, uint16 id) {
-	if (type > ARRAYSIZE(_archives[_archiveIndex].scriptContexts) ||
+	if (type >= ARRAYSIZE(_archives[_archiveIndex].scriptContexts) ||
 			!_archives[_archiveIndex].scriptContexts[type].contains(id)) {
 		return NULL;
 	}


Commit: e4e5719929bbcfe1c268a8fdaef133a3c0b20023
    https://github.com/scummvm/scummvm/commit/e4e5719929bbcfe1c268a8fdaef133a3c0b20023
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Sanity check

Changed paths:
    engines/director/lingo/lingo-code.cpp


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 1173441816..1d405b932e 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -781,8 +781,8 @@ void LC::c_of() {
 				break;
 			}
 		}
-		if (firstIndex < 0) {
-			warning("c_of: first_line out of range");
+		if (firstIndex < 0 || lastIndex < 0) {
+			warning("c_of: first_line or last_line out of range");
 			result = "";
 		} else {
 			result = result.substr(firstIndex, lastIndex);


Commit: a1cf5bf0eef1e3848666848e6e6b497d96dbaea2
    https://github.com/scummvm/scummvm/commit/a1cf5bf0eef1e3848666848e6e6b497d96dbaea2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:26+02:00

Commit Message:
DIRECTOR: Use reserve() instead of resize() for Arrays

Changed paths:
    engines/director/frame.cpp
    engines/director/lingo/lingo-the.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index cb1707d1e9..c89681ed1d 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -98,7 +98,7 @@ Frame::Frame(const Frame &frame) {
 
 	debugC(1, kDebugLoading, "Frame. action: %d transType: %d transDuration: %d", _actionId, _transType, _transDuration);
 
-	_sprites.resize(_numChannels + 1);
+	_sprites.reserve(_numChannels + 1);
 
 	for (uint16 i = 0; i <= _numChannels; i++) {
 		_sprites[i] = new Sprite(*frame._sprites[i]);
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index a35e4eb8c2..182ff9821d 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -274,7 +274,7 @@ void Lingo::initTheEntities() {
 	_objectEntityId = kTheObject;
 
 	TheEntity *e = entities;
-	_entityNames.resize(kTheMaxTheEntityType);
+	_entityNames.reserve(kTheMaxTheEntityType);
 
 	while (e->entity != kTheNOEntity) {
 		if (e->version <= _vm->getVersion()) {
@@ -287,7 +287,7 @@ void Lingo::initTheEntities() {
 	}
 
 	TheEntityField *f = fields;
-	_fieldNames.resize(kTheMaxTheFieldType);
+	_fieldNames.reserve(kTheMaxTheFieldType);
 
 	while (f->entity != kTheNOEntity) {
 		if (f->version <= _vm->getVersion()) {


Commit: 373d795c83bc907d4d3a06db2c12d9f46b3f07c6
    https://github.com/scummvm/scummvm/commit/373d795c83bc907d4d3a06db2c12d9f46b3f07c6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:27+02:00

Commit Message:
DIRECTOR: Initialize Symbol structure

Changed paths:
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index d4da8e3605..06738fa722 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -37,11 +37,15 @@ Lingo *g_lingo;
 
 Symbol::Symbol() {
 	type = VOID;
-	u.s = NULL;
+	u.s = nullptr;
 	nargs = 0;
 	maxArgs = 0;
 	parens = true;
 	global = false;
+	argNames = nullptr;
+	varNames = nullptr;
+	ctx = nullptr;
+	archiveIndex = 0;
 }
 
 Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {


Commit: 9ea0b3198e917d27271d691f046f5bbfdad3bd05
    https://github.com/scummvm/scummvm/commit/9ea0b3198e917d27271d691f046f5bbfdad3bd05
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:27+02:00

Commit Message:
DIRECTOR: Fix potential null pointer dereferences

Changed paths:
    engines/director/director.cpp
    engines/director/frame.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 30ed82dd22..61307c8c01 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -333,7 +333,10 @@ Common::HashMap<Common::String, Score *> *DirectorEngine::scanMovies(const Commo
 void DirectorEngine::enqueueAllMovies() {
 	Common::FSNode dir(ConfMan.get("path"));
 	Common::FSList files;
-	dir.getChildren(files, Common::FSNode::kListFilesOnly);
+	if (!dir.getChildren(files, Common::FSNode::kListFilesOnly)) {
+		warning("DirectorEngine::enqueueAllMovies(): Failed inquiring file list");
+		return;
+	}
 
 	for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file)
 		_movieQueue.push_back((*file).getName());
diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index c89681ed1d..06c483bef7 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -654,7 +654,11 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteId) {
 	byte foreColor = sp->_foreColor;
 	byte backColor = sp->_backColor;
 	int lineSize = sp->_thickness & 0x3;
-	if (spriteType == kCastMemberSprite && sp->_cast != NULL) {
+	if (spriteType == kCastMemberSprite) {
+		if (!sp->_cast) {
+			warning("Frame::renderShape(): kCastMemberSprite has no cast defined");
+			return;
+		}
 		switch (sp->_cast->_type) {
 		case kCastShape:
 			{


Commit: 0b7f54a89397dff83331464546a589cdb4582ba4
    https://github.com/scummvm/scummvm/commit/0b7f54a89397dff83331464546a589cdb4582ba4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:27+02:00

Commit Message:
DIRECTOR: Add sanity check to Lnam reading

Changed paths:
    engines/director/lingo/lingo-bytecode.cpp


diff --git a/engines/director/lingo/lingo-bytecode.cpp b/engines/director/lingo/lingo-bytecode.cpp
index 7eaf32920a..c7e9f4104e 100644
--- a/engines/director/lingo/lingo-bytecode.cpp
+++ b/engines/director/lingo/lingo-bytecode.cpp
@@ -678,6 +678,12 @@ void Lingo::addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType ty
 
 	// copy the storage area first.
 	uint32 constsStoreOffset = constsOffset + 6 * constsCount;
+
+	if (constsStoreOffset > stream.size()) {
+		warning("Lingo::addCodeV4(): Too big constsStoreOffset. %d > %d", constsStoreOffset, stream.size());
+		return;
+	}
+
 	uint32 constsStoreSize = stream.size() - constsStoreOffset;
 
 	if ((uint32)stream.size() < constsStoreOffset) {


Commit: 38bd50abb440fc3410af3772c2310e02bf9a745f
    https://github.com/scummvm/scummvm/commit/38bd50abb440fc3410af3772c2310e02bf9a745f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:27+02:00

Commit Message:
DIRECTOR: Fix memory overlap

Changed paths:
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 06738fa722..915423d063 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -388,8 +388,11 @@ int Datum::toInt() {
 		// no-op
 		break;
 	case FLOAT:
-		u.i = (int)u.f;
-		break;
+		{
+			int tmp = (int)u.f;
+			u.i = tmp;
+			break;
+		}
 	default:
 		warning("Incorrect operation toInt() for type: %s", type2str());
 	}
@@ -420,7 +423,10 @@ double Datum::toFloat() {
 		u.f = 0.0;
 		break;
 	case INT:
-		u.f = (double)u.i;
+		{
+			double tmp = (double)u.i;
+			u.f = tmp;
+		}
 		break;
 	case FLOAT:
 		// no-op


Commit: af9d122b0d7b77b7c06e17bd018ee6ae86bb6605
    https://github.com/scummvm/scummvm/commit/af9d122b0d7b77b7c06e17bd018ee6ae86bb6605
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-03T23:33:27+02:00

Commit Message:
DIRECTOR: Initialize Stxt

Changed paths:
    engines/director/stxt.cpp


diff --git a/engines/director/stxt.cpp b/engines/director/stxt.cpp
index 9dc0b75902..34f38244e6 100644
--- a/engines/director/stxt.cpp
+++ b/engines/director/stxt.cpp
@@ -34,6 +34,16 @@ Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
 	uint32 dataLen = textStream.readUint32();
 	Common::String text;
 
+	_fontId = 0;
+	_fontSize = 12;
+	_textType = kTextTypeFixed;
+	_textAlign = kTextAlignLeft;
+	_textShadow = kSizeNone;
+	_textSlant = 0;
+	_palinfo1 = _palinfo2 = _palinfo3 = 0;
+	_unk1f = _unk2f = 0;
+	_unk3f = 0;
+
 	for (uint32 i = 0; i < strLen; i++) {
 		byte ch = textStream.readByte();
 		if (ch == 0x0d) {




More information about the Scummvm-git-logs mailing list