summaryrefslogtreecommitdiff
path: root/src/delta.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/delta.c')
-rw-r--r--src/delta.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/delta.c b/src/delta.c
index 242f3abe3..d72d820d8 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -122,20 +122,13 @@ struct git_delta_index {
static int lookup_index_alloc(
void **out, unsigned long *out_len, size_t entries, size_t hash_count)
{
- size_t entries_len, hash_len,
- index_len = sizeof(struct git_delta_index);
+ size_t entries_len, hash_len, index_len;
- GITERR_CHECK_ALLOC_MULTIPLY(entries, sizeof(struct index_entry));
- entries_len = entries * sizeof(struct index_entry);
+ GITERR_CHECK_ALLOC_MULTIPLY(&entries_len, entries, sizeof(struct index_entry));
+ GITERR_CHECK_ALLOC_MULTIPLY(&hash_len, hash_count, sizeof(struct index_entry *));
- GITERR_CHECK_ALLOC_ADD(index_len, entries_len);
- index_len += entries_len;
-
- GITERR_CHECK_ALLOC_MULTIPLY(hash_count, sizeof(struct index_entry *));
- hash_len = hash_count * sizeof(struct index_entry *);
-
- GITERR_CHECK_ALLOC_ADD(index_len, hash_len);
- index_len += hash_len;
+ GITERR_CHECK_ALLOC_ADD(&index_len, sizeof(struct git_delta_index), entries_len);
+ GITERR_CHECK_ALLOC_ADD(&index_len, index_len, hash_len);
if (!git__is_ulong(index_len)) {
giterr_set(GITERR_NOMEMORY, "Overly large delta");