Allow bytes field to be longer than 16000 bytes (#157)

pull/13171/head
Paul Yang 6 years ago committed by GitHub
parent 0ca4edd7d9
commit a8a0bc73b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      upb/json/printer.c

@ -450,9 +450,14 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
UPB_UNUSED(handler_data);
UPB_UNUSED(handle);
print_data(p, "\"", 1);
while (remaining > 2) {
/* TODO(haberman): handle encoded lengths > sizeof(data) */
UPB_ASSERT((limit - to) >= 4);
if (limit - to < 4) {
bytes = to - data;
putstring(p, data, bytes);
to = data;
}
to[0] = base64[from[0] >> 2];
to[1] = base64[((from[0] & 0x3) << 4) | (from[1] >> 4)];
@ -484,7 +489,6 @@ static size_t putbytes(void *closure, const void *handler_data, const char *str,
}
bytes = to - data;
print_data(p, "\"", 1);
putstring(p, data, bytes);
print_data(p, "\"", 1);
return len;

Loading…
Cancel
Save