mirror of
https://github.com/godotengine/godot.git
synced 2024-11-15 08:32:54 +00:00
Don't allow to use in bit shift negative operands
This commit is contained in:
parent
df9c98e107
commit
2cbdcb03a1
@ -257,6 +257,14 @@ public:
|
|||||||
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
|
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
|
||||||
const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
|
const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
|
||||||
const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
|
const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
|
||||||
|
|
||||||
|
#if defined(DEBUG_ENABLED)
|
||||||
|
if (b < 0 || a < 0) {
|
||||||
|
*r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
|
||||||
|
r_valid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
*r_ret = a << b;
|
*r_ret = a << b;
|
||||||
r_valid = true;
|
r_valid = true;
|
||||||
}
|
}
|
||||||
@ -276,6 +284,14 @@ public:
|
|||||||
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
|
static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) {
|
||||||
const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
|
const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left);
|
||||||
const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
|
const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right);
|
||||||
|
|
||||||
|
#if defined(DEBUG_ENABLED)
|
||||||
|
if (b < 0 || a < 0) {
|
||||||
|
*r_ret = "Invalid operands for bit shifting. Only positive operands are supported.";
|
||||||
|
r_valid = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
*r_ret = a >> b;
|
*r_ret = a >> b;
|
||||||
r_valid = true;
|
r_valid = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user