submodule--helper: fix leak of core.worktree value
commit55fe225dde455ae32b9bc963bef4aabb9f5f7c3e
authorJeff King <peff@peff.net>
Mon, 17 Aug 2020 21:33:16 +0000 (17 17:33 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Aug 2020 22:35:47 +0000 (17 15:35 -0700)
tree3365f2e180db24d1ac0618327d8296ade0a81aeb
parent1c890016a147536e4a6faa5664eedd8765a01b32
submodule--helper: fix leak of core.worktree value

In the ensure_core_worktree() function, we load the core.worktree value
of the submodule repository using repo_config_get_string(). This
function copies the string, but we never free it, leaking the memory.

We can instead use the "tmp" version of that function to avoid the
allocation at all. We don't have to worry about lifetime issues, since
we never even look at the value (we just want to know if it's set).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c