Merge pull request #201 from veblush/ubsan2

Fixed ubsan error on memmove
pull/13171/head
Nicolas Noble 6 years ago committed by GitHub
commit b70f68269a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      upb/encode.c

@ -48,7 +48,9 @@ static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) {
CHK(new_buf);
/* We want previous data at the end, realloc() put it at the beginning. */
memmove(new_buf + new_size - old_size, e->buf, old_size);
if (old_size > 0) {
memmove(new_buf + new_size - old_size, e->buf, old_size);
}
e->ptr = new_buf + new_size - (e->limit - e->ptr);
e->limit = new_buf + new_size;

Loading…
Cancel
Save