diff options
author | Patryk Obara <patryk.obara@gmail.com> | 2017-08-18 20:33:13 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-08-18 12:18:10 -0700 |
commit | bc65d2262d7c676cc7a0100d8be84a0690e10702 (patch) | |
tree | c976febc8bc39eb48c45a8ce7fc2e7c629b0544b /commit.c | |
parent | commit: replace the raw buffer with strbuf in read_graft_line (diff) | |
download | tgif-bc65d2262d7c676cc7a0100d8be84a0690e10702.tar.xz |
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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; |