summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNinni Pipping <over999ships@gmail.com>2023-03-11 15:08:34 +0100
committerYuri Sizov <yuris@humnom.net>2023-03-27 17:23:58 +0200
commit7fe9c48e2bee9bf59d9c8c9f3f8d61258b62171a (patch)
tree266be881be9eb3ab29f074067b886760a5271fa5
parentfcedf5dfdf0814e789802bd58aef80fe299deec4 (diff)
Fix type check for max/min
(cherry picked from commit c8c43997c79b1488ca823af6c4ad4fd12f8671d4)
-rw-r--r--core/variant/variant_utility.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp
index 8f3ae65b9c..a6363039ba 100644
--- a/core/variant/variant_utility.cpp
+++ b/core/variant/variant_utility.cpp
@@ -542,7 +542,8 @@ struct VariantUtilityFunctions {
}
Variant base = *p_args[0];
Variant ret;
- for (int i = 1; i < p_argcount; i++) {
+
+ for (int i = 0; i < p_argcount; i++) {
Variant::Type arg_type = p_args[i]->get_type();
if (arg_type != Variant::INT && arg_type != Variant::FLOAT) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -550,6 +551,9 @@ struct VariantUtilityFunctions {
r_error.argument = i;
return Variant();
}
+ if (i == 0) {
+ continue;
+ }
bool valid;
Variant::evaluate(Variant::OP_LESS, base, *p_args[i], ret, valid);
if (!valid) {
@@ -582,7 +586,8 @@ struct VariantUtilityFunctions {
}
Variant base = *p_args[0];
Variant ret;
- for (int i = 1; i < p_argcount; i++) {
+
+ for (int i = 0; i < p_argcount; i++) {
Variant::Type arg_type = p_args[i]->get_type();
if (arg_type != Variant::INT && arg_type != Variant::FLOAT) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -590,6 +595,9 @@ struct VariantUtilityFunctions {
r_error.argument = i;
return Variant();
}
+ if (i == 0) {
+ continue;
+ }
bool valid;
Variant::evaluate(Variant::OP_GREATER, base, *p_args[i], ret, valid);
if (!valid) {