diff options
| author | Junio C Hamano <gitster@pobox.com> | 2017-09-19 10:47:55 +0900 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2017-09-19 10:47:55 +0900 |
| commit | 09595ab3818619a34281b85e1fb98802182e12a2 (patch) | |
| tree | 6f4074659713f2370682b7fc5c46d4e81573d60d /repository.c | |
| parent | df80c5760c947f2013df86f52d0a5103d07958a2 (diff) | |
| parent | 0e5bba53af7d6f911e99589d736cdf06badad0fe (diff) | |
| download | git-09595ab3818619a34281b85e1fb98802182e12a2.tar.gz | |
Merge branch 'jk/leak-checkers'
Many of our programs consider that it is OK to release dynamic
storage that is used throughout the life of the program by simply
exiting, but this makes it harder to leak detection tools to avoid
reporting false positives. Plug many existing leaks and introduce
a mechanism for developers to mark that the region of memory
pointed by a pointer is not lost/leaking to help these tools.
* jk/leak-checkers:
add UNLEAK annotation for reducing leak false positives
set_git_dir: handle feeding gitdir to itself
repository: free fields before overwriting them
reset: free allocated tree buffers
reset: make tree counting less confusing
config: plug user_config leak
update-index: fix cache entry leak in add_one_file()
add: free leaked pathspec after add_files_to_cache()
test-lib: set LSAN_OPTIONS to abort by default
test-lib: --valgrind should not override --verbose-log
Diffstat (limited to 'repository.c')
| -rw-r--r-- | repository.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/repository.c b/repository.c index f107af7d76..97c732bd48 100644 --- a/repository.c +++ b/repository.c @@ -40,11 +40,15 @@ static void repo_setup_env(struct repository *repo) repo->different_commondir = find_common_dir(&sb, repo->gitdir, !repo->ignore_env); + free(repo->commondir); repo->commondir = strbuf_detach(&sb, NULL); + free(repo->objectdir); repo->objectdir = git_path_from_env(DB_ENVIRONMENT, repo->commondir, "objects", !repo->ignore_env); + free(repo->graft_file); repo->graft_file = git_path_from_env(GRAFT_ENVIRONMENT, repo->commondir, "info/grafts", !repo->ignore_env); + free(repo->index_file); repo->index_file = git_path_from_env(INDEX_ENVIRONMENT, repo->gitdir, "index", !repo->ignore_env); } @@ -52,16 +56,12 @@ static void repo_setup_env(struct repository *repo) void repo_set_gitdir(struct repository *repo, const char *path) { const char *gitfile = read_gitfile(path); + char *old_gitdir = repo->gitdir; - /* - * NEEDSWORK: Eventually we want to be able to free gitdir and the rest - * of the environment before reinitializing it again, but we have some - * crazy code paths where we try to set gitdir with the current gitdir - * and we don't want to free gitdir before copying the passed in value. - */ repo->gitdir = xstrdup(gitfile ? gitfile : path); - repo_setup_env(repo); + + free(old_gitdir); } /* |
