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

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
yexo 15 years ago
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…
Cancel
Save