diff options
author | yexo <yexo@openttd.org> | 2009-08-23 19:25:52 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-08-23 19:25:52 +0000 |
commit | f9c18ccc48735f46a57e21c93ccb2eabc36dee56 (patch) | |
tree | ab14430db479f129ddfe18bc2f0f03150b828871 /src | |
parent | b841250913c310fb55c4a3cbc2016831079a1e7c (diff) | |
download | openttd-f9c18ccc48735f46a57e21c93ccb2eabc36dee56.tar.xz |
(svn r17273) -Fix [Squirrel]: calling a function that has default parameters with not enough parameters can cause a crash
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/squirrel/squirrel/sqvm.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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]; } |