Thread (17 messages) flat view 17 messages, 6 authors, 2022-06-17
STALE1522d

[PATCH 07/11] submodule--helper: avoid memory leak when fetching submodules

From: Johannes Schindelin via GitGitGadget <hidden>
Date: 2022-06-15 23:36:10
Subsystem: the rest · Maintainer: Linus Torvalds

From: Johannes Schindelin <redacted>

In c51f8f94e5b3 (submodule--helper: run update procedures from C,
2021-08-24), we added code that first obtains the default remote, and
then adds that to a `strvec`.

However, we never released the default remote's memory.

Reported by Coverity.

Signed-off-by: Johannes Schindelin <redacted>
---
 builtin/submodule--helper.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d7b8004b933..9a8248ffe6a 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2208,6 +2208,7 @@ static int fetch_in_submodule(const char *module_path, int depth, int quiet, str
 		char *hex = oid_to_hex(oid);
 		char *remote = get_default_remote();
 		strvec_pushl(&cp.args, remote, hex, NULL);
+		free(remote);
 	}
 
 	return run_command(&cp);
-- 
gitgitgadget
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help