aboutsummaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_functions.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2018-02-19 21:35:53 +0100
committerGitHub2018-02-19 21:35:53 +0100
commitaeed774fef63c37b6894d889d6dc98202ee24ed0 (patch)
treea9c8c37a4e8bb498d4af5ea42f19f2855da0b62e /modules/gdscript/gdscript_functions.cpp
parentf163b0e4b4da163de121503ca93aad212f053be4 (diff)
parent802d5c4c6c30d0f218b60245ca397cf8f5ed1b5d (diff)
downloadgodot-aeed774fef63c37b6894d889d6dc98202ee24ed0.tar.gz
godot-aeed774fef63c37b6894d889d6dc98202ee24ed0.tar.zst
godot-aeed774fef63c37b6894d889d6dc98202ee24ed0.zip
Merge pull request #16173 from vnen/gdscript-arguments
Add argument count check for some GDScript functions
Diffstat (limited to '')
-rw-r--r--modules/gdscript/gdscript_functions.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index c067d5409..278585cb0 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -358,13 +358,16 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = Math::dectime((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
} break;
case MATH_RANDOMIZE: {
+ VALIDATE_ARG_COUNT(0);
Math::randomize();
r_ret = Variant();
} break;
case MATH_RAND: {
+ VALIDATE_ARG_COUNT(0);
r_ret = Math::rand();
} break;
case MATH_RANDF: {
+ VALIDATE_ARG_COUNT(0);
r_ret = Math::randf();
} break;
case MATH_RANDOM: {
@@ -593,7 +596,13 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
r_ret = String(result);
} break;
case TEXT_STR: {
+ if (p_arg_count < 1) {
+ r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.argument = 1;
+ r_ret = Variant();
+ return;
+ }
String str;
for (int i = 0; i < p_arg_count; i++) {
@@ -1180,6 +1189,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
} break;
case PRINT_STACK: {
+ VALIDATE_ARG_COUNT(0);
ScriptLanguage *script = GDScriptLanguage::get_singleton();
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {