diff --git a/upb/decode.c b/upb/decode.c index 6b04ff7031..2bc4d9c818 100644 --- a/upb/decode.c +++ b/upb/decode.c @@ -694,7 +694,11 @@ bool upb_decode(const char *buf, size_t size, void *msg, const upb_msglayout *l, decode_stealmem(&state); +#ifdef __APPLE__ + if (_setjmp(state.err)) { +#else if (setjmp(state.err)) { +#endif ret = false; } else { decode_msg(&state, buf, msg, l); diff --git a/upb/decode_fast.c b/upb/decode_fast.c index 71be07a4a8..e6da81b049 100644 --- a/upb/decode_fast.c +++ b/upb/decode_fast.c @@ -262,9 +262,14 @@ again: } { - int64_t len = ptr[tagbytes]; - if (UPB_UNLIKELY(len < 0)) { - return fastdecode_generic(UPB_PARSE_ARGS); + uint32_t len = (uint8_t)ptr[tagbytes]; + if (UPB_UNLIKELY(len & 0x80)) { + uint32_t byte = (uint8_t)ptr[tagbytes + 1]; + len += (byte - 1) << 7; + if (UPB_UNLIKELY(byte & 0x80)) { + return fastdecode_generic(UPB_PARSE_ARGS); + } + ptr++; } ptr += tagbytes + 1; if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, len, d->limit))) {