Merge pull request #210 from haberman/asanfix

A memory safety fix, found by ASAN.
pull/13171/head
Joshua Haberman 5 years ago committed by GitHub
commit cdb3779e99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      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;
}

Loading…
Cancel
Save