From f9c18ccc48735f46a57e21c93ccb2eabc36dee56 Mon Sep 17 00:00:00 2001 From: yexo Date: Sun, 23 Aug 2009 19:25:52 +0000 Subject: (svn r17273) -Fix [Squirrel]: calling a function that has default parameters with not enough parameters can cause a crash --- src/3rdparty/squirrel/squirrel/sqvm.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/3rdparty') diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index c2ca7e19c..c3cdeae30 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -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]; } -- cgit v1.2.3-70-g09d2