diff options
| author | George Marques | 2018-01-30 01:32:08 -0200 |
|---|---|---|
| committer | George Marques | 2018-01-30 01:32:08 -0200 |
| commit | 802d5c4c6c30d0f218b60245ca397cf8f5ed1b5d (patch) | |
| tree | b98cf5d1bc45ef8e4b568b3c0e62d37fc56c8f0a /modules/gdscript/gdscript_functions.cpp | |
| parent | 9f3138eea99b776a82bb1243a963b8e47adbc9c3 (diff) | |
| download | godot-802d5c4c6c30d0f218b60245ca397cf8f5ed1b5d.tar.gz godot-802d5c4c6c30d0f218b60245ca397cf8f5ed1b5d.tar.zst godot-802d5c4c6c30d0f218b60245ca397cf8f5ed1b5d.zip | |
Add argument count check for some GDScript functions
- Print functions have no check.
- Also remove extra apostrophe from the error report.
Diffstat (limited to '')
| -rw-r--r-- | modules/gdscript/gdscript_functions.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp index eceec2781..07378c2f3 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++) { |
