aboutsummaryrefslogtreecommitdiffstats
path: root/rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-07-24 15:10:52 -0700
committerJunio C Hamano <gitster@pobox.com>2015-07-24 15:11:02 -0700
commit7d4053b69b37927c0ccd98eac41f32707227eca0 (patch)
treea9461bbf6bc0473d0013e80d01bb3a7c6e3083db /rerere.c
parent74444d4ec4c23d254040de7b2637660b7f141110 (diff)
downloadgit-7d4053b69b37927c0ccd98eac41f32707227eca0.tar.gz
rerere: do not leak mmfile[] for a path with multiple stage #1 entries
A conflicted index can have multiple stage #1 entries when dealing with a criss-cross merge and using the "resolve" merge strategy. Plug the leak by reading only the first one of the same stage entries. Strictly speaking, this fix does change the semantics, in that we used to use the last stage #1 entry as the common ancestor when doing the plain-vanilla three-way merge, but with the leak fix, we will use the first stage #1 entry. But it is not a grave backward compatibility breakage. Either way, we are arbitrarily picking one of multiple stage #1 entries and using it, ignoring others, and there is no meaning in the ordering of these stage #1 entries. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/rerere.c b/rerere.c
index e1d527c250..d665debf0f 100644
--- a/rerere.c
+++ b/rerere.c
@@ -337,8 +337,10 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
if (ce_namelen(ce) != len || memcmp(ce->name, path, len))
break;
i = ce_stage(ce) - 1;
- mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
- mmfile[i].size = size;
+ if (!mmfile[i].ptr) {
+ mmfile[i].ptr = read_sha1_file(ce->sha1, &type, &size);
+ mmfile[i].size = size;
+ }
}
for (i = 0; i < 3; i++)
if (!mmfile[i].ptr && !mmfile[i].size)