Commit b33e018cab1faf95208556cb54ae16b6c7449552

Edward Thomson 2021-03-04T09:20:34

Merge pull request #5818 from mamapanda/patch-3 merge: Check insert_head_ids error in create_virtual_base

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/src/merge.c b/src/merge.c
index e02ea91..82b028b 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;