Fixed varint length when buffer is reallocated.

pull/13171/head
Joshua Haberman 7 years ago
parent be9094d91a
commit b697882fb2
  1. 6
      tests/conformance_upb_failures.txt
  2. 4
      upb/encode.c

@ -12,10 +12,4 @@ Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput
Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
Required.ProtobufInput.ValidDataScalar.BOOL.ProtobufOutput Required.ProtobufInput.ValidDataScalar.BOOL.ProtobufOutput

@ -167,12 +167,12 @@ static bool upb_encode_array(upb_encstate *e, const char *field_mem,
#define VARINT_CASE(ctype, encode) { \ #define VARINT_CASE(ctype, encode) { \
ctype *start = arr->data; \ ctype *start = arr->data; \
ctype *ptr = start + arr->len; \ ctype *ptr = start + arr->len; \
char *buf_ptr = e->ptr; \ size_t pre_len = e->limit - e->ptr; \
do { \ do { \
ptr--; \ ptr--; \
CHK(upb_put_varint(e, encode)); \ CHK(upb_put_varint(e, encode)); \
} while (ptr != start); \ } while (ptr != start); \
CHK(upb_put_varint(e, buf_ptr - e->ptr)); \ CHK(upb_put_varint(e, e->limit - e->ptr - pre_len)); \
} \ } \
break; \ break; \
do { ; } while(0) do { ; } while(0)

Loading…
Cancel
Save