diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-10-29 15:43:12 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-29 15:43:13 -0700 |
commit | 55b99febc40308985f319ae3feaa23070abebdb7 (patch) | |
tree | 7b46887918dfdc64235355b5eeab68687aee2dfd | |
parent | Merge branch 'ab/ref-filter-leakfix' (diff) | |
parent | config.c: don't leak memory in handle_path_include() (diff) | |
download | tgif-55b99febc40308985f319ae3feaa23070abebdb7.tar.xz |
Merge branch 'ab/plug-handle-path-exclude-leak'
Leakfix.
* ab/plug-handle-path-exclude-leak:
config.c: don't leak memory in handle_path_include()
-rw-r--r-- | config.c | 7 | ||||
-rwxr-xr-x | t/t1305-config-include.sh | 1 |
2 files changed, 6 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; diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh index ccbb116c01..5cde79ef8c 100755 --- a/t/t1305-config-include.sh +++ b/t/t1305-config-include.sh @@ -1,6 +1,7 @@ #!/bin/sh test_description='test config file include directives' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh # Force setup_explicit_git_dir() to run until the end. This is needed |