Thread (162 messages) 162 messages, 2 authors, 2022-09-01
STALE1378d

[PATCH v4 02/17] submodule--helper: fix trivial get_default_remote_submodule() leak

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2022-07-28 16:30:31
Subsystem: the rest · Maintainer: Linus Torvalds

Fix a leak in code added in 1012a5cbc3f (submodule--helper
run-update-procedure: learn --remote, 2022-03-04), we need to free()
the xstrdup()'d string. This gets e.g. t/t7419-submodule-set-branch.sh
closer to passing under SANITIZE=leak.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 builtin/submodule--helper.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d3dd47588d5..d452af40d2d 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2410,6 +2410,8 @@ static int update_submodule(struct update_data *update_data,
 		const char *branch = remote_submodule_branch(update_data->sm_path);
 		char *remote_ref = xstrfmt("refs/remotes/%s/%s", remote_name, branch);
 
+		free(remote_name);
+
 		if (!update_data->nofetch) {
 			if (fetch_in_submodule(update_data->sm_path, update_data->depth,
 					      0, NULL))
-- 
2.37.1.1197.g7ed548b7807
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help