Squashed 'third_party/upb/' changes from 4c6dcc3c6b..ca84145476

ca84145476 [decoder] fix for buf=NULL, size=0 case. (#246)

git-subtree-dir: third_party/upb
git-subtree-split: ca84145476ddd722c6d67d7cf985d1d0aefcd893
pull/23140/head
Mark D. Roth 5 years ago
parent 4f76446806
commit 6a2cb9b2f8
  1. 12
      tests/test_generated_code.c
  2. 3
      upb/decode.c

@ -340,11 +340,23 @@ void test_repeated() {
upb_arena_free(arena);
}
void test_null_decode_buf() {
upb_arena *arena = upb_arena_new();
protobuf_test_messages_proto3_TestAllTypesProto3 *msg =
protobuf_test_messages_proto3_TestAllTypesProto3_parse(NULL, 0, arena);
size_t size;
ASSERT(msg);
protobuf_test_messages_proto3_TestAllTypesProto3_serialize(msg, arena, &size);
ASSERT(size == 0);
}
int run_tests(int argc, char *argv[]) {
test_scalars();
test_string_map();
test_string_double_map();
test_int32_map();
test_repeated();
test_null_decode_buf();
return 0;
}

@ -622,6 +622,9 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l,
state.depth = 64;
state.end_group = 0;
/* Early exit required for buf==NULL case. */
if (size == 0) return true;
CHK(upb_decode_message(buf, l, msg, &state));
return state.end_group == 0;
}

Loading…
Cancel
Save