summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-06-10 21:39:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-12 17:29:42 (GMT)
commit10322a0aaf84382d8901f9ab59e59c39f0c035bb (patch)
tree970192cbf707078dc581dd734242fd5db166fc77 /merge-recursive.c
parent969eba6341a5af8ac52c67e26462548ed05e23e3 (diff)
downloadgit-10322a0aaf84382d8901f9ab59e59c39f0c035bb.zip
git-10322a0aaf84382d8901f9ab59e59c39f0c035bb.tar.gz
git-10322a0aaf84382d8901f9ab59e59c39f0c035bb.tar.bz2
do not create "struct commit" with xcalloc
In both blame and merge-recursive, we sometimes create a "fake" commit struct for convenience (e.g., to represent the HEAD state as if we would commit it). By allocating ourselves rather than using alloc_commit_node, we do not properly set the "index" field of the commit. This can produce subtle bugs if we then use commit-slab on the resulting commit, as we will share the "0" index with another commit. We can fix this by using alloc_commit_node() to allocate. Note that we cannot free the result, as it is part of our commit allocator. However, both cases were already leaking the allocated commit anyway, so there's nothing to fix up. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 4177092..fc2a68a 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -40,7 +40,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
{
- struct commit *commit = xcalloc(1, sizeof(struct commit));
+ struct commit *commit = alloc_commit_node();
struct merge_remote_desc *desc = xmalloc(sizeof(*desc));
desc->name = comment;