summaryrefslogtreecommitdiff
path: root/src/3rdparty
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-08-23 19:25:52 +0000
committeryexo <yexo@openttd.org>2009-08-23 19:25:52 +0000
commitf9c18ccc48735f46a57e21c93ccb2eabc36dee56 (patch)
treeab14430db479f129ddfe18bc2f0f03150b828871 /src/3rdparty
parentb841250913c310fb55c4a3cbc2016831079a1e7c (diff)
downloadopenttd-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/3rdparty')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp4
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];
}