Subject: [PATCH 2/2] Fix mem leak in branch.c due to not-free newly added virtual_name variable

From: "ctmbl via GitGitGadget" <[email-masked]>
Date: Wed, 22 Mar 2023 09:42:06 +0000

From: ctmbl <[email-masked]>

Previous commit introduced virtual_name variable which is the name of
the branch in case it has been a remote ref (used to check whether the
user simply forgot `--remote` flag) but didn't free it.
Call FREE_AND_NULL(virtual_name) to solve it.

Signed-off-by: Clement Mabileau <[email-masked]>
---
 builtin/branch.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/branch.c b/builtin/branch.c
index 8e768761b9b..697636e2874 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -279,6 +279,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
 							| RESOLVE_REF_NO_RECURSE
 							| RESOLVE_REF_ALLOW_BAD_NAME,
 							&oid, &flags);
+				FREE_AND_NULL(virtual_name);
 				if (virtual_target)
 					error(_(MISSING_BRANCH_HINT_MSG), bname.buf);
 				else
-- 
gitgitgadget