summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRafał Mikrut <mikrutrafal54@gmail.com>2019-12-12 20:00:26 +0100
committerRafał Mikrut <mikrutrafal54@gmail.com>2019-12-12 20:00:26 +0100
commit162a64efcd3cd95035e7dce3403452fd4dfdbd9a (patch)
tree395db3fa7a56d91817d2ece69f657a4d444363f1 /core
parent8eb183aebb9c79ff92d6f566af7ad2f91696ce08 (diff)
Don't allow to use too big or too small shift operators
Diffstat (limited to 'core')
-rw-r--r--core/variant_op.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index ea9e29e744..ae47397558 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1118,6 +1118,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SHIFT_LEFT, INT) {
if (p_b.type != INT)
_RETURN_FAIL;
+ if (p_b._data._int < 0 || p_b._data._int >= 64)
+ _RETURN_FAIL;
_RETURN(p_a._data._int << p_b._data._int);
}
@@ -1129,6 +1131,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SHIFT_RIGHT, INT) {
if (p_b.type != INT)
_RETURN_FAIL;
+ if (p_b._data._int < 0 || p_b._data._int >= 64)
+ _RETURN_FAIL;
_RETURN(p_a._data._int >> p_b._data._int);
}