Merge pull request #22223 from Faless/fix_int32_encode

Fix put_var encoding some 32bits ints as 64bits.
This commit is contained in:
Rémi Verschelde 2018-10-02 09:40:21 +02:00 committed by GitHub
commit ffa8420aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -807,7 +807,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::INT: {
int64_t val = p_variant;
if (val > 0x7FFFFFFF || val < -0x80000000) {
if (val > (int64_t)INT_MAX || val < (int64_t)INT_MIN) {
flags |= ENCODE_FLAG_64;
}
} break;
@ -851,7 +851,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
case Variant::INT: {
int64_t val = p_variant;
if (val > 0x7FFFFFFF || val < -0x80000000) {
if (flags & ENCODE_FLAG_64) {
//64 bits
if (buf) {
encode_uint64(val, buf);
@ -870,7 +870,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
double d = p_variant;
float f = d;
if (double(f) != d) {
if (flags & ENCODE_FLAG_64) {
if (buf) {
encode_double(p_variant.operator double(), buf);
}