1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-16 02:59:10 +00:00

(svn r17273) -Fix [Squirrel]: calling a function that has default parameters with not enough parameters can cause a crash

This commit is contained in:
yexo
2009-08-23 19:25:52 +00:00
parent b841250913
commit f9c18ccc48

View File

@@ -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];
}