Commit 2b6e1908 by Russell Belfer

A bit of item alignment paranoia

parent 8d9a85d4
...@@ -258,7 +258,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) ...@@ -258,7 +258,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
int error = 0; int error = 0;
khiter_t pos; khiter_t pos;
void *item; void *item;
size_t keylen; size_t keylen, itemlen;
char *item_key; char *item_key;
pos = git_strmap_lookup_index(sc->map, key); pos = git_strmap_lookup_index(sc->map, key);
...@@ -267,9 +267,12 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key) ...@@ -267,9 +267,12 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
goto done; goto done;
} }
keylen = strlen(key); keylen = strlen(key);
item = git_pool_mallocz(&sc->pool, sc->item_path_offset + keylen + 1); itemlen = sc->item_path_offset + keylen + 1;
if (!item) { /* don't use GITERR_CHECK_ALLOC b/c of lock */ itemlen = (itemlen + 7) & ~7;
if ((item = git_pool_mallocz(&sc->pool, itemlen)) == NULL) {
/* don't use GITERR_CHECK_ALLOC b/c of lock */
error = -1; error = -1;
goto done; goto done;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment