Commit dc1095a5b7a1c17a11d9bc70a93c2191d78f4c18

panda 2021-03-03T14:42:12

merge: Check insert_head_ids error in create_virtual_base insert_head_ids can fail due to allocation error

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;