diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-10-21 21:54:14 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-21 16:26:45 -0700 |
commit | 25ad722126c77a546ab1ac7111f090bd8d0e3c13 (patch) | |
tree | 38b7c848341c7e6ecbe2891836fce0282bd5afc3 /config.c | |
parent | 9d530dc0024503ab4218fe6c4395b8a0aa245478 (diff) | |
download | git-25ad722126c77a546ab1ac7111f090bd8d0e3c13.tar.gz |
config.c: don't leak memory in handle_path_include()
Fix a memory leak in the error() path in handle_path_include(), this
allows us to run t1305-config-include.sh under SANITIZE=leak,
previously 4 tests there would fail. This fixes up a leak in
9b25a0b52e0 (config: add include directive, 2012-02-06).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -148,8 +148,10 @@ static int handle_path_include(const char *path, struct config_include_data *inc if (!is_absolute_path(path)) { char *slash; - if (!cf || !cf->path) - return error(_("relative config includes must come from files")); + if (!cf || !cf->path) { + ret = error(_("relative config includes must come from files")); + goto cleanup; + } slash = find_last_dir_sep(cf->path); if (slash) @@ -167,6 +169,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc ret = git_config_from_file(git_config_include, path, inc); inc->depth--; } +cleanup: strbuf_release(&buf); free(expanded); return ret; |