vendor/libgit2/src/sortedcache.c in rugged-0.22.2 vs vendor/libgit2/src/sortedcache.c in rugged-0.23.0b1

- old
+ new

@@ -1,22 +1,24 @@ #include "sortedcache.h" -GIT__USE_STRMAP; +GIT__USE_STRMAP int git_sortedcache_new( git_sortedcache **out, size_t item_path_offset, git_sortedcache_free_item_fn free_item, void *free_item_payload, git_vector_cmp item_cmp, const char *path) { git_sortedcache *sc; - size_t pathlen; + size_t pathlen, alloclen; pathlen = path ? strlen(path) : 0; - sc = git__calloc(sizeof(git_sortedcache) + pathlen + 1, 1); + GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_sortedcache), pathlen); + GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1); + sc = git__calloc(1, alloclen); GITERR_CHECK_ALLOC(sc); if (git_pool_init(&sc->pool, 1, 0) < 0 || git_vector_init(&sc->items, 4, item_cmp) < 0 || git_strmap_alloc(&sc->map) < 0)