Bugfixes to upb_stdio and upb_decoder.

pull/13171/head
Joshua Haberman 15 years ago
parent 87b2c69c15
commit 60ae9be438
  1. 3
      stream/upb_decoder.c
  2. 2
      stream/upb_stdio.c

@ -91,10 +91,10 @@ static bool upb_decoder_nextbuf(upb_decoder *d)
// Recycle old buffer.
if(d->buf) {
d->buf = upb_string_tryrecycle(d->buf);
d->buf_offset -= upb_string_len(d->buf);
d->buf_stream_offset += upb_string_len(d->buf);
}
d->buf = upb_string_tryrecycle(d->buf);
// Pull next buffer.
if(upb_bytesrc_get(d->bytesrc, d->buf, UPB_MAX_ENCODED_SIZE)) {
@ -569,6 +569,7 @@ void upb_decoder_reset(upb_decoder *d, upb_bytesrc *bytesrc)
// to UINT32_MAX so it doesn't equal UPB_GROUP_END_OFFSET.
d->top->end_offset = UINT32_MAX - 1;
d->bytesrc = bytesrc;
d->field = NULL;
d->buf = NULL;
d->buf_bytesleft = 0;
d->buf_stream_offset = 0;

@ -53,7 +53,7 @@ bool upb_stdio_append(upb_bytesrc *src, upb_string *str, upb_strlen_t len) {
}
int32_t upb_stdio_put(upb_bytesink *sink, upb_string *str) {
upb_stdio *stdio = (upb_stdio*)sink - offsetof(upb_stdio, bytesink);
upb_stdio *stdio = (upb_stdio*)((char*)sink - offsetof(upb_stdio, bytesink));
upb_strlen_t len = upb_string_len(str);
size_t written = fwrite(upb_string_getrobuf(str), 1, len, stdio->file);
if(written < len) {

Loading…
Cancel
Save