mirror of
https://github.com/git-for-windows/git.git
synced 2025-12-12 15:59:24 -06:00
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>
This commit is contained in:
parent
d292bfaf35
commit
4e2d094dde
@ -196,7 +196,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
|
|||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
name = xstrdup(mkpath(fmt, bname.buf));
|
name = mkpathdup(fmt, bname.buf);
|
||||||
if (read_ref(name, sha1)) {
|
if (read_ref(name, sha1)) {
|
||||||
error(remote_branch
|
error(remote_branch
|
||||||
? _("remote branch '%s' not found.")
|
? _("remote branch '%s' not found.")
|
||||||
|
|||||||
@ -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 */
|
/* Beware: real_path() and mkpath() return static buffer */
|
||||||
ref_git = xstrdup(real_path(item->string));
|
ref_git = xstrdup(real_path(item->string));
|
||||||
if (is_directory(mkpath("%s/.git/objects", ref_git))) {
|
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);
|
free(ref_git);
|
||||||
ref_git = ref_git_git;
|
ref_git = ref_git_git;
|
||||||
} else if (!is_directory(mkpath("%s/objects", ref_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);
|
git_dir = xstrdup(dir);
|
||||||
else {
|
else {
|
||||||
work_tree = dir;
|
work_tree = dir;
|
||||||
git_dir = xstrdup(mkpath("%s/.git", dir));
|
git_dir = mkpathdup("%s/.git", dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!option_bare) {
|
if (!option_bare) {
|
||||||
|
|||||||
@ -168,7 +168,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
prune_packed_objects(show_only);
|
prune_packed_objects(show_only);
|
||||||
remove_temporary_files(get_object_directory());
|
remove_temporary_files(get_object_directory());
|
||||||
s = xstrdup(mkpath("%s/pack", get_object_directory()));
|
s = mkpathdup("%s/pack", get_object_directory());
|
||||||
remove_temporary_files(s);
|
remove_temporary_files(s);
|
||||||
free(s);
|
free(s);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -862,14 +862,14 @@ static int merge_3way(struct merge_options *o,
|
|||||||
if (strcmp(a->path, b->path) ||
|
if (strcmp(a->path, b->path) ||
|
||||||
(o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
|
(o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
|
||||||
base_name = o->ancestor == NULL ? NULL :
|
base_name = o->ancestor == NULL ? NULL :
|
||||||
xstrdup(mkpath("%s:%s", o->ancestor, one->path));
|
mkpathdup("%s:%s", o->ancestor, one->path);
|
||||||
name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
|
name1 = mkpathdup("%s:%s", branch1, a->path);
|
||||||
name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
|
name2 = mkpathdup("%s:%s", branch2, b->path);
|
||||||
} else {
|
} else {
|
||||||
base_name = o->ancestor == NULL ? NULL :
|
base_name = o->ancestor == NULL ? NULL :
|
||||||
xstrdup(mkpath("%s", o->ancestor));
|
mkpathdup("%s", o->ancestor);
|
||||||
name1 = xstrdup(mkpath("%s", branch1));
|
name1 = mkpathdup("%s", branch1);
|
||||||
name2 = xstrdup(mkpath("%s", branch2));
|
name2 = mkpathdup("%s", branch2);
|
||||||
}
|
}
|
||||||
|
|
||||||
read_mmblob(&orig, one->sha1);
|
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,
|
merge_status = ll_merge(result_buf, a->path, &orig, base_name,
|
||||||
&src1, name1, &src2, name2, &ll_opts);
|
&src1, name1, &src2, name2, &ll_opts);
|
||||||
|
|
||||||
|
free(base_name);
|
||||||
free(name1);
|
free(name1);
|
||||||
free(name2);
|
free(name2);
|
||||||
free(orig.ptr);
|
free(orig.ptr);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user