зеркало из https://github.com/microsoft/git.git
builtin/rebase.c: fix "options.onto_name" leak
Similar to the existing "squash_onto_name" added in [1] we need to free() the xstrdup()'d "options.onto.name" added for "--keep-base" in [2].. 1.9dba809a69
(builtin rebase: support --root, 2018-09-04) 2.414d924beb
(rebase: teach rebase --keep-base, 2019-08-27) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
a6a700a43c
Коммит
94ad545d47
|
@ -1039,6 +1039,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||||
struct string_list strategy_options = STRING_LIST_INIT_NODUP;
|
struct string_list strategy_options = STRING_LIST_INIT_NODUP;
|
||||||
struct object_id squash_onto;
|
struct object_id squash_onto;
|
||||||
char *squash_onto_name = NULL;
|
char *squash_onto_name = NULL;
|
||||||
|
char *keep_base_onto_name = NULL;
|
||||||
int reschedule_failed_exec = -1;
|
int reschedule_failed_exec = -1;
|
||||||
int allow_preemptive_ff = 1;
|
int allow_preemptive_ff = 1;
|
||||||
int preserve_merges_selected = 0;
|
int preserve_merges_selected = 0;
|
||||||
|
@ -1675,7 +1676,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
||||||
strbuf_addstr(&buf, options.upstream_name);
|
strbuf_addstr(&buf, options.upstream_name);
|
||||||
strbuf_addstr(&buf, "...");
|
strbuf_addstr(&buf, "...");
|
||||||
strbuf_addstr(&buf, branch_name);
|
strbuf_addstr(&buf, branch_name);
|
||||||
options.onto_name = xstrdup(buf.buf);
|
options.onto_name = keep_base_onto_name = xstrdup(buf.buf);
|
||||||
} else if (!options.onto_name)
|
} else if (!options.onto_name)
|
||||||
options.onto_name = options.upstream_name;
|
options.onto_name = options.upstream_name;
|
||||||
if (strstr(options.onto_name, "...")) {
|
if (strstr(options.onto_name, "...")) {
|
||||||
|
@ -1851,6 +1852,7 @@ cleanup:
|
||||||
free(options.strategy);
|
free(options.strategy);
|
||||||
strbuf_release(&options.git_format_patch_opt);
|
strbuf_release(&options.git_format_patch_opt);
|
||||||
free(squash_onto_name);
|
free(squash_onto_name);
|
||||||
|
free(keep_base_onto_name);
|
||||||
string_list_clear(&strategy_options, 0);
|
string_list_clear(&strategy_options, 0);
|
||||||
return !!ret;
|
return !!ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ test_description='git rebase --onto A...B'
|
||||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
. "$TEST_DIRECTORY/lib-rebase.sh"
|
. "$TEST_DIRECTORY/lib-rebase.sh"
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче