mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 14:50:17 +00:00
DIRECTOR: LINGO: Add guardrail for implicit factory calls
It is possible to have a script which looks like a factory, but has normal functions in it also. Calling those normal functions should not apply the bodge which injects the me object as argument 1.
This commit is contained in:
parent
64cc8adb3c
commit
10ac6b61d8
@ -1554,10 +1554,13 @@ void LC::call(const Common::String &name, int nargs, bool allowRetVal) {
|
||||
if (g_lingo->_state->me.type == OBJECT) {
|
||||
AbstractObject *target = g_lingo->_state->me.u.obj;
|
||||
funcSym = target->getMethod(name);
|
||||
if (funcSym.type != VOIDSYM) {
|
||||
if (name.hasPrefixIgnoreCase("m") && funcSym.type != VOIDSYM) {
|
||||
if (nargs == 0) {
|
||||
debugC(3, kDebugLingoExec, "Factory method call detected with missing first arg");
|
||||
g_lingo->_stack.push_back(Datum());
|
||||
nargs = 1;
|
||||
} else {
|
||||
debugC(3, kDebugLingoExec, "Factory method call detected with invalid first arg: <%s>", g_lingo->_stack[g_lingo->_stack.size() - nargs].asString(true).c_str());
|
||||
}
|
||||
g_lingo->_stack[g_lingo->_stack.size() - nargs] = funcSym.target; // Set first arg to target
|
||||
call(funcSym, nargs, allowRetVal);
|
||||
|
Loading…
Reference in New Issue
Block a user