Commit 31e84edb14327050ba74bf213c5b17451cca311e

Edward Thomson 2021-07-19T16:02:30

merge: don't try to malloc(0)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/merge.c b/src/merge.c
index 82b028b..c29b40e 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -1535,7 +1535,8 @@ int git_merge_diff_list__find_renames(
 	GIT_ASSERT_ARG(diff_list);
 	GIT_ASSERT_ARG(opts);
 
-	if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0)
+	if ((opts->flags & GIT_MERGE_FIND_RENAMES) == 0 ||
+	    !diff_list->conflicts.length)
 		return 0;
 
 	similarity_ours = git__calloc(diff_list->conflicts.length,