Skip to content

Commit dc1095a

Browse files
committed
merge: Check insert_head_ids error in create_virtual_base
insert_head_ids can fail due to allocation error
1 parent 935f851 commit dc1095a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/merge.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,8 +2277,11 @@ static int create_virtual_base(
22772277
result->type = GIT_ANNOTATED_COMMIT_VIRTUAL;
22782278
result->index = index;
22792279

2280-
insert_head_ids(&result->parents, one);
2281-
insert_head_ids(&result->parents, two);
2280+
if (insert_head_ids(&result->parents, one) < 0 ||
2281+
insert_head_ids(&result->parents, two) < 0) {
2282+
git_annotated_commit_free(result);
2283+
return -1;
2284+
}
22822285

22832286
*out = result;
22842287
return 0;

0 commit comments

Comments
 (0)