mirror of https://github.com/OpenTTD/OpenTTD
(svn r17273) -Fix [Squirrel]: calling a function that has default parameters with not enough parameters can cause a crash
parent
b841250913
commit
f9c18ccc48
|
@ -336,6 +336,10 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
|
|||
SQInteger ndef = func->_ndefaultparams;
|
||||
if(ndef && nargs < paramssize) {
|
||||
SQInteger diff = paramssize - nargs;
|
||||
if (diff > ndef) {
|
||||
Raise_Error(_SC("wrong number of parameters"));
|
||||
return false;
|
||||
}
|
||||
for(SQInteger n = ndef - diff; n < ndef; n++) {
|
||||
_stack._vals[stackbase + (nargs++)] = closure->_defaultparams[n];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue