diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-05-07 12:47:41 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-07 12:47:41 +0900 |
commit | 936e58851af0324d408c9e1a70cddd288d892a45 (patch) | |
tree | 6c0eaca13d0c6f4d7343d773a994441b042d1729 /builtin | |
parent | Merge branch 'ps/rev-list-object-type-filter' (diff) | |
parent | builtin/rm: avoid leaking pathspec and seen (diff) | |
download | tgif-936e58851af0324d408c9e1a70cddd288d892a45.tar.xz |
Merge branch 'ah/plugleaks'
Plug various leans reported by LSAN.
* ah/plugleaks:
builtin/rm: avoid leaking pathspec and seen
builtin/rebase: release git_format_patch_opt too
builtin/for-each-ref: free filter and UNLEAK sorting.
mailinfo: also free strbuf lists when clearing mailinfo
builtin/checkout: clear pending objects after diffing
builtin/check-ignore: clear_pathspec before returning
builtin/bugreport: don't leak prefixed filename
branch: FREE_AND_NULL instead of NULL'ing real_ref
bloom: clear each bloom_key after use
ls-files: free max_prefix when done
wt-status: fix multiple small leaks
revision: free remainder of old commit list in limit_list
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/bugreport.c | 8 | ||||
-rw-r--r-- | builtin/check-ignore.c | 1 | ||||
-rw-r--r-- | builtin/checkout.c | 1 | ||||
-rw-r--r-- | builtin/for-each-ref.c | 3 | ||||
-rw-r--r-- | builtin/ls-files.c | 3 | ||||
-rw-r--r-- | builtin/rebase.c | 1 | ||||
-rw-r--r-- | builtin/rm.c | 2 |
7 files changed, 15 insertions, 4 deletions
diff --git a/builtin/bugreport.c b/builtin/bugreport.c index ad3cc9c02f..9915a5841d 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -129,6 +129,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) char *option_output = NULL; char *option_suffix = "%Y-%m-%d-%H%M"; const char *user_relative_path = NULL; + char *prefixed_filename; const struct option bugreport_options[] = { OPT_STRING('o', "output-directory", &option_output, N_("path"), @@ -142,9 +143,9 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) bugreport_usage, 0); /* Prepare the path to put the result */ - strbuf_addstr(&report_path, - prefix_filename(prefix, - option_output ? option_output : "")); + prefixed_filename = prefix_filename(prefix, + option_output ? option_output : ""); + strbuf_addstr(&report_path, prefixed_filename); strbuf_complete(&report_path, '/'); strbuf_addstr(&report_path, "git-bugreport-"); @@ -189,6 +190,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix) fprintf(stderr, _("Created new report at '%s'.\n"), user_relative_path); + free(prefixed_filename); UNLEAK(buffer); UNLEAK(report_path); return !!launch_editor(report_path.buf, NULL, NULL); diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c index 0f4480a11b..81234552b7 100644 --- a/builtin/check-ignore.c +++ b/builtin/check-ignore.c @@ -119,6 +119,7 @@ static int check_ignore(struct dir_struct *dir, num_ignored++; } free(seen); + clear_pathspec(&pathspec); return num_ignored; } diff --git a/builtin/checkout.c b/builtin/checkout.c index 5bd9128d1a..4d19c35d83 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -607,6 +607,7 @@ static void show_local_changes(struct object *head, diff_setup_done(&rev.diffopt); add_pending_object(&rev, head, NULL); run_diff_index(&rev, 0); + object_array_clear(&rev.pending); } static void describe_detached_head(const char *msg, struct commit *commit) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index b529228c62..89cb6307d4 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -94,5 +94,8 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) strbuf_release(&err); strbuf_release(&output); ref_array_clear(&array); + free_commit_list(filter.with_commit); + free_commit_list(filter.no_commit); + UNLEAK(sorting); return 0; } diff --git a/builtin/ls-files.c b/builtin/ls-files.c index a0b4e54d11..ecaca5e2fe 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -607,7 +607,7 @@ static int option_parse_exclude_standard(const struct option *opt, int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) { int require_work_tree = 0, show_tag = 0, i; - const char *max_prefix; + char *max_prefix; struct dir_struct dir; struct pattern_list *pl; struct string_list exclude_list = STRING_LIST_INIT_NODUP; @@ -785,5 +785,6 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) } dir_clear(&dir); + free(max_prefix); return 0; } diff --git a/builtin/rebase.c b/builtin/rebase.c index ed1da1760e..a756fba233 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -2109,6 +2109,7 @@ cleanup: free(options.head_name); free(options.gpg_sign_opt); free(options.cmd); + strbuf_release(&options.git_format_patch_opt); free(squash_onto_name); return ret; } diff --git a/builtin/rm.c b/builtin/rm.c index d89f241e97..8a24c715e0 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -342,6 +342,8 @@ int cmd_rm(int argc, const char **argv, const char *prefix) if (!seen_any) exit(ret); } + clear_pathspec(&pathspec); + free(seen); if (!index_only) submodules_absorb_gitdir_if_needed(); |