summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2012-09-04 18:31:14 +0100
committerJunio C Hamano <gitster@pobox.com>2012-09-04 13:34:46 -0700
commit4e2d094dde4f078245d057dd6111ab9d013ae6d0 (patch)
tree208226504d771a78580d6f8a78277134c3b3ecc1 /merge-recursive.c
parentd292bfaf356338b41e14e40ce4dbd6b9c8d600ec (diff)
downloadgit-4e2d094dde4f078245d057dd6111ab9d013ae6d0.tar.gz
Call mkpathdup() rather than xstrdup(mkpath(...))
In addition to updating the xstrdup(mkpath(...)) call sites with mkpathdup(), we also fix a memory leak (in merge_3way()) caused by neglecting to free the memory allocated to the 'base_name' variable. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 39b2e165e0..2f8febe0e0 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -862,14 +862,14 @@ static int merge_3way(struct merge_options *o,
if (strcmp(a->path, b->path) ||
(o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
base_name = o->ancestor == NULL ? NULL :
- xstrdup(mkpath("%s:%s", o->ancestor, one->path));
- name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
- name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+ mkpathdup("%s:%s", o->ancestor, one->path);
+ name1 = mkpathdup("%s:%s", branch1, a->path);
+ name2 = mkpathdup("%s:%s", branch2, b->path);
} else {
base_name = o->ancestor == NULL ? NULL :
- xstrdup(mkpath("%s", o->ancestor));
- name1 = xstrdup(mkpath("%s", branch1));
- name2 = xstrdup(mkpath("%s", branch2));
+ mkpathdup("%s", o->ancestor);
+ name1 = mkpathdup("%s", branch1);
+ name2 = mkpathdup("%s", branch2);
}
read_mmblob(&orig, one->sha1);
@@ -879,6 +879,7 @@ static int merge_3way(struct merge_options *o,
merge_status = ll_merge(result_buf, a->path, &orig, base_name,
&src1, name1, &src2, name2, &ll_opts);
+ free(base_name);
free(name1);
free(name2);
free(orig.ptr);