diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-09-04 13:51:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 13:51:34 -0700 |
commit | cdb3779e9928661d45f7b06520e020674ed41615 (patch) | |
tree | fbbe5908181ffc40a3a9b70de226030f2d193fee /upb/table.c | |
parent | 4e77dc16c14248d46a0ed92e47f190326aff1d39 (diff) | |
parent | 555b60b0626bdcb6e0436625177c375f75664247 (diff) |
Merge pull request #210 from haberman/asanfix
A memory safety fix, found by ASAN.
Diffstat (limited to 'upb/table.c')
-rw-r--r-- | upb/table.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/upb/table.c b/upb/table.c index 13f8d81..8896d21 100644 --- a/upb/table.c +++ b/upb/table.c @@ -276,7 +276,8 @@ static upb_tabkey strcopy(lookupkey_t k2, upb_alloc *a) { char *str = upb_malloc(a, k2.str.len + sizeof(uint32_t) + 1); if (str == NULL) return 0; memcpy(str, &len, sizeof(uint32_t)); - memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len + 1); + memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len); + str[sizeof(uint32_t) + k2.str.len] = '\0'; return (uintptr_t)str; } |