Merge pull request #22223 from Faless/fix_int32_encode
Fix put_var encoding some 32bits ints as 64bits.
This commit is contained in:
commit
ffa8420aec
1 changed files with 3 additions and 3 deletions
|
@ -807,7 +807,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||||
|
|
||||||
case Variant::INT: {
|
case Variant::INT: {
|
||||||
int64_t val = p_variant;
|
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;
|
flags |= ENCODE_FLAG_64;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -851,7 +851,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
|
||||||
case Variant::INT: {
|
case Variant::INT: {
|
||||||
|
|
||||||
int64_t val = p_variant;
|
int64_t val = p_variant;
|
||||||
if (val > 0x7FFFFFFF || val < -0x80000000) {
|
if (flags & ENCODE_FLAG_64) {
|
||||||
//64 bits
|
//64 bits
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_uint64(val, 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;
|
double d = p_variant;
|
||||||
float f = d;
|
float f = d;
|
||||||
if (double(f) != d) {
|
if (flags & ENCODE_FLAG_64) {
|
||||||
if (buf) {
|
if (buf) {
|
||||||
encode_double(p_variant.operator double(), buf);
|
encode_double(p_variant.operator double(), buf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue