diff options
Diffstat (limited to 'src/odb_mempack.c')
| -rw-r--r-- | src/odb_mempack.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/odb_mempack.c b/src/odb_mempack.c index d9b3a1824..34355270f 100644 --- a/src/odb_mempack.c +++ b/src/odb_mempack.c @@ -18,7 +18,7 @@ #include "git2/types.h" #include "git2/pack.h" -GIT__USE_OIDMAP; +GIT__USE_OIDMAP struct memobject { git_oid oid; @@ -38,6 +38,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void struct memory_packer_db *db = (struct memory_packer_db *)_backend; struct memobject *obj = NULL; khiter_t pos; + size_t alloc_len; int rval; pos = kh_put(oid, db->objects, oid, &rval); @@ -47,7 +48,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void if (rval == 0) return 0; - obj = git__malloc(sizeof(struct memobject) + len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(struct memobject), len); + obj = git__malloc(alloc_len); GITERR_CHECK_ALLOC(obj); memcpy(obj->data, data, len); |
