summaryrefslogtreecommitdiff
path: root/src/sortedcache.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-08-22 11:50:10 -0700
committerRussell Belfer <rb@github.com>2013-08-22 11:50:10 -0700
commit2b6e1908476c95c84d3e3a62ac069f789156b070 (patch)
treee6b39d147655415a7c10610558d742eaefd41e2c /src/sortedcache.c
parent8d9a85d43aa6ed7a9fb15a2ac9e0f9ba1c33461e (diff)
downloadlibgit2-2b6e1908476c95c84d3e3a62ac069f789156b070.tar.gz
A bit of item alignment paranoia
Diffstat (limited to 'src/sortedcache.c')
-rw-r--r--src/sortedcache.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/sortedcache.c b/src/sortedcache.c
index c087dbbe9..16dd6a7a1 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -258,7 +258,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
int error = 0;
khiter_t pos;
void *item;
- size_t keylen;
+ size_t keylen, itemlen;
char *item_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)
goto done;
}
- keylen = strlen(key);
- item = git_pool_mallocz(&sc->pool, sc->item_path_offset + keylen + 1);
- if (!item) { /* don't use GITERR_CHECK_ALLOC b/c of lock */
+ keylen = strlen(key);
+ itemlen = sc->item_path_offset + keylen + 1;
+ 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;
goto done;
}