diff options
Diffstat (limited to 'upb/bytestream.c')
-rw-r--r-- | upb/bytestream.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/upb/bytestream.c b/upb/bytestream.c index 4f6e4b1..812e552 100644 --- a/upb/bytestream.c +++ b/upb/bytestream.c @@ -32,6 +32,8 @@ upb_byteregion *upb_byteregion_newl(const void *str, size_t len) { memcpy(ptr, str, len); ptr[len] = '\0'; upb_stringsrc_reset(src, ptr, len); + upb_byteregion_fetch(upb_stringsrc_allbytes(src)); + assert(len == upb_byteregion_available(upb_stringsrc_allbytes(src), 0)); return upb_stringsrc_allbytes(src); } @@ -241,9 +243,10 @@ upb_bytesink* upb_stdio_bytesink(upb_stdio *stdio) { return &stdio->sink; } upb_bytesuccess_t upb_stringsrc_fetch(void *_src, uint64_t ofs, size_t *read) { upb_stringsrc *src = _src; - assert(ofs < src->len); + assert(ofs <= src->len); if (ofs == src->len) { upb_status_seteof(&src->bytesrc.status); + *read = 0; return UPB_BYTE_EOF; } *read = src->len - ofs; |