mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 11:03:13 -05:00
Don't allow to use too big or too small shift operators
This commit is contained in:
parent
8eb183aebb
commit
162a64efcd
1 changed files with 4 additions and 0 deletions
|
@ -1118,6 +1118,8 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
|
||||||
CASE_TYPE(math, OP_SHIFT_LEFT, INT) {
|
CASE_TYPE(math, OP_SHIFT_LEFT, INT) {
|
||||||
if (p_b.type != INT)
|
if (p_b.type != INT)
|
||||||
_RETURN_FAIL;
|
_RETURN_FAIL;
|
||||||
|
if (p_b._data._int < 0 || p_b._data._int >= 64)
|
||||||
|
_RETURN_FAIL;
|
||||||
_RETURN(p_a._data._int << p_b._data._int);
|
_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) {
|
CASE_TYPE(math, OP_SHIFT_RIGHT, INT) {
|
||||||
if (p_b.type != INT)
|
if (p_b.type != INT)
|
||||||
_RETURN_FAIL;
|
_RETURN_FAIL;
|
||||||
|
if (p_b._data._int < 0 || p_b._data._int >= 64)
|
||||||
|
_RETURN_FAIL;
|
||||||
_RETURN(p_a._data._int >> p_b._data._int);
|
_RETURN(p_a._data._int >> p_b._data._int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue