summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpanda <daniel.phan36@gmail.com>2021-03-03 14:42:12 -0800
committerpanda <daniel.phan36@gmail.com>2021-03-03 14:46:56 -0800
commitdc1095a5b7a1c17a11d9bc70a93c2191d78f4c18 (patch)
tree7b9c79188c97aa3afd1a35203b6a9d9e09541f72
parent935f85131fa106730bbf66d49808b5aca375f729 (diff)
downloadlibgit2-dc1095a5b7a1c17a11d9bc70a93c2191d78f4c18.tar.gz
merge: Check insert_head_ids error in create_virtual_base
insert_head_ids can fail due to allocation error
-rw-r--r--src/merge.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/merge.c b/src/merge.c
index e02ea9169..82b028b4a 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -2277,8 +2277,11 @@ static int create_virtual_base(
result->type = GIT_ANNOTATED_COMMIT_VIRTUAL;
result->index = index;
- insert_head_ids(&result->parents, one);
- insert_head_ids(&result->parents, two);
+ if (insert_head_ids(&result->parents, one) < 0 ||
+ insert_head_ids(&result->parents, two) < 0) {
+ git_annotated_commit_free(result);
+ return -1;
+ }
*out = result;
return 0;