Skip to content

Fix all leaks in tests t0002-t0099: Part 2

[email protected] git 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest12 patches 7 repliesIn review
  2. v112 patches 18 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12fmt-merge-msg: free newly allocated temporary strings when donefmt-merge-msg.c+4 -21 reply
2/12environment: move strbuf into block to plug leakenvironment.c+3 -40 replies
3/12builtin/submodule--helper: release unused strbuf to avoid leakbuiltin/submodule--helper.c+4 -20 replies
4/12builtin/for-each-repo: remove unnecessary argv copy to plug leakbuiltin/for-each-repo.c+4 -101 reply
5/12diffcore-rename: move old_dir/new_dir definition to plug leakdiffcore-rename.c+7 -31 reply
6/12ref-filter: also free head for ATOM_HEAD to avoid leakref-filter.c+6 -21 reply
7/12read-cache: call diff_setup_done to avoid leakread-cache.c+1 -01 reply
8/12convert: release strbuf to avoid leakconvert.c+2 -01 reply
9/12builtin/mv: free or UNLEAK multiple pointers at end of cmd_mvbuiltin/mv.c+5 -00 replies
10/12builtin/merge: free found_ref when donebuiltin/merge.c+2 -10 replies
11/12builtin/rebase: fix options.strategy memory lifecyclebuiltin/rebase.c+2 -10 replies
12/12reset: clear_unpack_trees_porcelain to plug leakreset.c+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/12] Fix all leaks in tests t0002-t0099: Part 2

From: Andrzej Hunt <[email protected]>

V2 fixes patch 11/12 (rebase_options.strategy lifecycle) as per review discussion. Many thanks to Phillip and Elijah for spotting the issues there!

ATB,

Andrzej

Andrzej Hunt (12):
fmt-merge-msg: free newly allocated temporary strings when done
environment: move strbuf into block to plug leak builtin/submodule--helper: release unused strbuf to avoid leak builtin/for-each-repo: remove unnecessary argv copy to plug leak
diffcore-rename: move old_dir/new_dir definition to plug leak
ref-filter: also free head for ATOM_HEAD to avoid leak
read-cache: call diff_setup_done to avoid leak
convert: release strbuf to avoid leak
builtin/mv: free or UNLEAK multiple pointers at end of cmd_mv builtin/merge: free found_ref when done builtin/rebase: fix options.strategy memory lifecycle
reset: clear_unpack_trees_porcelain to plug leak

 builtin/for-each-repo.c     | 14 ++++----------
 builtin/merge.c             |  3 ++-
 builtin/mv.c                |  5 +++++
 builtin/rebase.c            |  3 ++-
 builtin/submodule--helper.c |  6 ++++--
 convert.c                   |  2 ++
 diffcore-rename.c           | 10 +++++++---
 environment.c               |  7 +++----
 fmt-merge-msg.c             |  6 ++++--
 read-cache.c                |  1 +
 ref-filter.c                |  8 ++++++--
 reset.c                     |  4 ++--
 12 files changed, 42 insertions(+), 27 deletions(-)

Interdiff against v1:

builtin/rebase.c +3 -1
index 9d81db0f3a..33e0961900 100644
@@ -1723,6 +1723,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	}
 
 	if (options.strategy) {
+		options.strategy = xstrdup(options.strategy);
 		switch (options.type) {
 		case REBASE_APPLY:
 			die(_("--strategy requires --merge or --interactive"));
@@ -1775,7 +1776,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	if (options.type == REBASE_MERGE &&
 	    !options.strategy &&
 	    getenv("GIT_TEST_MERGE_ALGORITHM"))
-		options.strategy = getenv("GIT_TEST_MERGE_ALGORITHM");
+		options.strategy = xstrdup(getenv("GIT_TEST_MERGE_ALGORITHM"));
 
 	switch (options.type) {
 	case REBASE_MERGE:
@@ -2108,6 +2109,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 	free(options.head_name);
 	free(options.gpg_sign_opt);
 	free(options.cmd);
+	free(options.strategy);
 	strbuf_release(&options.git_format_patch_opt);
 	free(squash_onto_name);
 	return ret;
Signature · 1 line
2.26.2