diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-08-31 23:14:08 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-09-02 16:18:12 (GMT) |
commit | e77b3da6bb60e9af5963c9e42442afe53af1780b (patch) | |
tree | 044a80f2f7c651034027133b88f6573098607631 /t/t1500-rev-parse.sh | |
parent | 5647d743e39d51e79407869ba30decc64e736557 (diff) | |
download | git-e77b3da6bb60e9af5963c9e42442afe53af1780b.zip git-e77b3da6bb60e9af5963c9e42442afe53af1780b.tar.gz git-e77b3da6bb60e9af5963c9e42442afe53af1780b.tar.bz2 |
submodule--helper: fix a leak in "clone_submodule"
Fix a memory leak of the "clone_data_path" variable that we copy or
derive from the "struct module_clone_data" in clone_submodule(). This
code was refactored in preceding commits, but the leak has been with
us since f8eaa0ba98b (submodule--helper, module_clone: always operate
on absolute paths, 2016-03-31).
For the "else" case we don't need to xstrdup() the "clone_data->path",
and we don't need to free our own "clone_data_path". We can therefore
assign the "clone_data->path" to our own "clone_data_path" right away,
and only override it (and remember to free it!) if we need to
xstrfmt() a replacement.
In the case of the module_clone() caller it's from "argv", and doesn't
need to be free'd, and in the case of the add_submodule() caller we
get a pointer to "sm_path", which doesn't need to be directly free'd
either.
Fixing this leak makes several tests pass, so let's mark them as
passing with TEST_PASSES_SANITIZE_LEAK=true.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1500-rev-parse.sh')
-rwxr-xr-x | t/t1500-rev-parse.sh | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 1c2df08..0e13bcb 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -4,6 +4,7 @@ test_description='test git rev-parse' GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_one () { |