From: Junio C Hamano Date: Fri, 7 May 2021 03:47:41 +0000 (+0900) Subject: Merge branch 'ah/plugleaks' X-Git-Tag: v2.32.0-rc0~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=936e58851a;p=thirdparty%2Fgit.git 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 --- 936e58851af0324d408c9e1a70cddd288d892a45 diff --cc builtin/for-each-ref.c index b529228c62,84efb71f82..89cb6307d4 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@@ -82,17 -80,11 +82,20 @@@ int cmd_for_each_ref(int argc, const ch if (!maxcount || array.nr < maxcount) maxcount = array.nr; - for (i = 0; i < maxcount; i++) - show_ref_array_item(array.items[i], &format); + for (i = 0; i < maxcount; i++) { + strbuf_reset(&err); + strbuf_reset(&output); + if (format_ref_array_item(array.items[i], &format, &output, &err)) + die("%s", err.buf); + fwrite(output.buf, 1, output.len, stdout); + putchar('\n'); + } + + 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 --cc builtin/rm.c index d89f241e97,2927678d37..8a24c715e0 --- a/builtin/rm.c +++ b/builtin/rm.c @@@ -332,16 -324,11 +332,18 @@@ int cmd_rm(int argc, const char **argv *original ? original : "."); } + if (only_match_skip_worktree.nr) { + advise_on_updating_sparse_paths(&only_match_skip_worktree); + ret = 1; + } + free(skip_worktree_seen); + string_list_clear(&only_match_skip_worktree, 0); + if (!seen_any) - exit(0); + exit(ret); } + clear_pathspec(&pathspec); + free(seen); if (!index_only) submodules_absorb_gitdir_if_needed();