Merge pull request #450 from stanhu/sh-fix-conformance-tests-big-endian

Fix conformance test failures on big-endian systems
pull/13171/head
Joshua Haberman 3 years ago committed by GitHub
commit 643e43c3e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      upb/decode.c
  2. 3
      upb/json_decode.c

@ -278,7 +278,7 @@ static void decode_munge(int type, wireval *val) {
val->bool_val = val->uint64_val != 0;
break;
case UPB_DESCRIPTOR_TYPE_SINT32: {
uint32_t n = val->uint32_val;
uint32_t n = val->uint64_val;
val->uint32_val = (n >> 1) ^ -(int32_t)(n & 1);
break;
}

@ -719,7 +719,8 @@ static upb_msgval jsondec_int(jsondec *d, const upb_fielddef *f) {
jsondec_err(d, "Expected number or string");
}
if (upb_fielddef_type(f) == UPB_TYPE_INT32) {
if (upb_fielddef_type(f) == UPB_TYPE_INT32 ||
upb_fielddef_type(f) == UPB_TYPE_ENUM) {
if (val.int64_val > INT32_MAX || val.int64_val < INT32_MIN) {
jsondec_err(d, "Integer out of range.");
}

Loading…
Cancel
Save