Merge pull request #119 from rohitsakala/master

Bugfix for bigendian platforms by casting size_t to unint32_t
pull/13171/head
Joshua Haberman 6 years ago committed by GitHub
commit 62318cadce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      upb/table.c

@ -270,9 +270,10 @@ static size_t begin(const upb_table *t) {
/* A simple "subclass" of upb_table that only adds a hash function for strings. */ /* A simple "subclass" of upb_table that only adds a hash function for strings. */
static upb_tabkey strcopy(lookupkey_t k2, upb_alloc *a) { static upb_tabkey strcopy(lookupkey_t k2, upb_alloc *a) {
uint32_t len = (uint32_t) k2.str.len;
char *str = upb_malloc(a, k2.str.len + sizeof(uint32_t) + 1); char *str = upb_malloc(a, k2.str.len + sizeof(uint32_t) + 1);
if (str == NULL) return 0; if (str == NULL) return 0;
memcpy(str, &k2.str.len, sizeof(uint32_t)); 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 + 1);
return (uintptr_t)str; return (uintptr_t)str;
} }

Loading…
Cancel
Save