[Scummvm-git-logs] scummvm master -> 4dd7fb4c73ff535d092771db79d9e7a407e847ff

djsrv dservilla at gmail.com
Wed Jul 22 19:01:29 UTC 2020


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:
4dd7fb4c73 DIRECTOR: LINGO: Clear garbage from loops


Commit: 4dd7fb4c73ff535d092771db79d9e7a407e847ff
    https://github.com/scummvm/scummvm/commit/4dd7fb4c73ff535d092771db79d9e7a407e847ff
Author: djsrv (dservilla at gmail.com)
Date: 2020-07-22T15:00:53-04:00

Commit Message:
DIRECTOR: LINGO: Clear garbage from loops

There are some temporary values left on the stack when returning from
within a loop.

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


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index b24a6e221f..aa9ce7c27d 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1328,14 +1328,19 @@ void LB::b_quit(int nargs) {
 
 void LB::b_return(int nargs) {
 	CFrame *fp = g_lingo->_callstack.back();
-	// Do not allow a factory's mNew method to return a value
-	// Otherwise do not touch the top of the stack, it will be returned
-	if (g_lingo->_currentMe.type == OBJECT && g_lingo->_currentMe.u.obj->getObjType() == kFactoryObj && fp->sp.name->equalsIgnoreCase("mNew")) {
+
+	Datum retVal = g_lingo->pop();
+	g_lingo->_theResult = retVal;	// Store result for possible reference
+
+	// clear any temp values from loops
+	while (g_lingo->_stack.size() > fp->stackSizeBefore)
 		g_lingo->pop();
-	}
 
-	if (!g_lingo->_stack.empty())
-		g_lingo->_theResult = g_lingo->peek(0);	// Store result for possible reference
+	// Do not allow a factory's mNew method to return a value
+	if (!(g_lingo->_currentMe.type == OBJECT && g_lingo->_currentMe.u.obj->getObjType() == kFactoryObj
+			&& fp->sp.name->equalsIgnoreCase("mNew"))) {
+		g_lingo->push(retVal);
+	}
 
 	LC::c_procret();
 }




More information about the Scummvm-git-logs mailing list