From 4e2d094dde4f078245d057dd6111ab9d013ae6d0 Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Tue, 4 Sep 2012 18:31:14 +0100 Subject: 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 Signed-off-by: Junio C Hamano --- builtin/clone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'builtin/clone.c') diff --git a/builtin/clone.c b/builtin/clone.c index e314b0b6d2..c819757b3a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -236,7 +236,7 @@ static int add_one_reference(struct string_list_item *item, void *cb_data) /* Beware: real_path() and mkpath() return static buffer */ ref_git = xstrdup(real_path(item->string)); if (is_directory(mkpath("%s/.git/objects", ref_git))) { - char *ref_git_git = xstrdup(mkpath("%s/.git", ref_git)); + char *ref_git_git = mkpathdup("%s/.git", ref_git); free(ref_git); ref_git = ref_git_git; } else if (!is_directory(mkpath("%s/objects", ref_git))) @@ -700,7 +700,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) git_dir = xstrdup(dir); else { work_tree = dir; - git_dir = xstrdup(mkpath("%s/.git", dir)); + git_dir = mkpathdup("%s/.git", dir); } if (!option_bare) { -- cgit v1.2.1