summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorPatryk Obara <patryk.obara@gmail.com>2017-08-18 20:33:13 +0200
committerJunio C Hamano <gitster@pobox.com>2017-08-18 12:18:10 -0700
commitbc65d2262d7c676cc7a0100d8be84a0690e10702 (patch)
treec976febc8bc39eb48c45a8ce7fc2e7c629b0544b /commit.c
parent9a9340329a7151697c943794369950115963879f (diff)
downloadgit-bc65d2262d7c676cc7a0100d8be84a0690e10702.tar.gz
commit: allocate array using object_id size
struct commit_graft aggregates an array of object_id's, which have size >= GIT_MAX_RAWSZ bytes. This change prevents memory allocation error when size of object_id is larger than GIT_SHA1_RAWSZ. Signed-off-by: Patryk Obara <patryk.obara@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index 1a0a9f23e9..c2d2de2d74 100644
--- a/commit.c
+++ b/commit.c
@@ -147,7 +147,8 @@ struct commit_graft *read_graft_line(struct strbuf *line)
if ((line->len + 1) % entry_size)
goto bad_graft_data;
i = (line->len + 1) / entry_size - 1;
- graft = xmalloc(st_add(sizeof(*graft), st_mult(GIT_SHA1_RAWSZ, i)));
+ graft = xmalloc(st_add(sizeof(*graft),
+ st_mult(sizeof(struct object_id), i)));
graft->nr_parent = i;
if (get_oid_hex(line->buf, &graft->oid))
goto bad_graft_data;