[PATCH 17/30] merge-recursive: Fix leaks of allocated renames and diff_filepairs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



get_renames() has always zero'ed out diff_queued_diff.nr while only
manually free'ing diff_filepairs that did not correspond to renames.
Further, it allocated struct renames that were tucked away in the
return string_list.  Make sure all of these are deallocated when we
are done with them.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 merge-recursive.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 49710c0964..7a3402e50c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1661,10 +1661,21 @@ static struct rename_info *handle_renames(struct merge_options *o,
 
 static void cleanup_renames(struct rename_info *re_info)
 {
-	string_list_clear(re_info->head_renames, 0);
-	string_list_clear(re_info->merge_renames, 0);
+	const struct rename *re;
+	int i;
 
+	for (i = 0; i < re_info->head_renames->nr; i++) {
+		re = re_info->head_renames->items[i].util;
+		diff_free_filepair(re->pair);
+	}
+	string_list_clear(re_info->head_renames, 1);
 	free(re_info->head_renames);
+
+	for (i = 0; i < re_info->merge_renames->nr; i++) {
+		re = re_info->merge_renames->items[i].util;
+		diff_free_filepair(re->pair);
+	}
+	string_list_clear(re_info->merge_renames, 1);
 	free(re_info->merge_renames);
 
 	free(re_info);
-- 
2.15.0.5.g9567be9905




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux