|
|
@ -124,7 +124,7 @@ static bool in_residual_buf(const upb_pbdecoder *d, const char *p) { |
|
|
|
// and the parsing stack, so must be called whenever either is updated.
|
|
|
|
// and the parsing stack, so must be called whenever either is updated.
|
|
|
|
static void set_delim_end(upb_pbdecoder *d) { |
|
|
|
static void set_delim_end(upb_pbdecoder *d) { |
|
|
|
size_t delim_ofs = d->top->end_ofs - d->bufstart_ofs; |
|
|
|
size_t delim_ofs = d->top->end_ofs - d->bufstart_ofs; |
|
|
|
if (delim_ofs <= (d->end - d->buf)) { |
|
|
|
if (delim_ofs <= (size_t)(d->end - d->buf)) { |
|
|
|
d->delim_end = d->buf + delim_ofs; |
|
|
|
d->delim_end = d->buf + delim_ofs; |
|
|
|
d->data_end = d->delim_end; |
|
|
|
d->data_end = d->delim_end; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -268,7 +268,7 @@ static NOINLINE int32_t getbytes_slow(upb_pbdecoder *d, void *buf, |
|
|
|
advancetobuf(d, d->buf_param, d->size_param); |
|
|
|
advancetobuf(d, d->buf_param, d->size_param); |
|
|
|
} |
|
|
|
} |
|
|
|
if (curbufleft(d) >= bytes) { |
|
|
|
if (curbufleft(d) >= bytes) { |
|
|
|
consumebytes(d, buf + avail, bytes); |
|
|
|
consumebytes(d, (char *)buf + avail, bytes); |
|
|
|
return DECODE_OK; |
|
|
|
return DECODE_OK; |
|
|
|
} else if (d->data_end == d->delim_end) { |
|
|
|
} else if (d->data_end == d->delim_end) { |
|
|
|
seterr(d, "Submessage ended in the middle of a value or group"); |
|
|
|
seterr(d, "Submessage ended in the middle of a value or group"); |
|
|
@ -296,7 +296,7 @@ static NOINLINE size_t peekbytes_slow(upb_pbdecoder *d, void *buf, |
|
|
|
memcpy(buf, d->ptr, ret); |
|
|
|
memcpy(buf, d->ptr, ret); |
|
|
|
if (in_residual_buf(d, d->ptr)) { |
|
|
|
if (in_residual_buf(d, d->ptr)) { |
|
|
|
size_t copy = UPB_MIN(bytes - ret, d->size_param); |
|
|
|
size_t copy = UPB_MIN(bytes - ret, d->size_param); |
|
|
|
memcpy(buf + ret, d->buf_param, copy); |
|
|
|
memcpy((char *)buf + ret, d->buf_param, copy); |
|
|
|
ret += copy; |
|
|
|
ret += copy; |
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|