summaryrefslogtreecommitdiff
path: root/upb
diff options
context:
space:
mode:
authorEsun Kim <veblush@google.com>2019-07-31 17:46:38 -0700
committerEsun Kim <veblush@google.com>2019-07-31 17:46:38 -0700
commit3838f62aa505fcfd106bc19d2160587225805fa8 (patch)
tree57963f6cc54e0b15d995c0d8c23799aa7f056b4b /upb
parent638d114a1ac20a79bf7490eef6625f15bc61d52b (diff)
Fixed ubsan error on memmove
Diffstat (limited to 'upb')
-rw-r--r--upb/encode.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/upb/encode.c b/upb/encode.c
index 7ec952e..43d24cd 100644
--- a/upb/encode.c
+++ b/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;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback