git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
CGctmbl via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 22, 2023, 09:42 UTC
Message-ID
<27f27f3afd76fc974350c0c94e20307879eead84.1679478126.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1476.git.git.1679478126.gitgitgadget@gmail.com>
From: ctmbl <mabileau.clement@gmail.com>

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 <mabileau.clement@gmail.com>
---
 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
Previous: ClementMabileau via GitGitGadgetNext: Junio C Hamano
Message 2 of 13 in “branch: improve error log on branch not found by checking remotes refs”
  1. 0/2 branch: improve error log on branch not found by checking remotes refsClementMabileau via GitGitGadget, Mar 22, 2023
  2. 2/2 Fix mem leak in branch.c due to not-free newly added virtual_name variablectmbl via GitGitGadget, Mar 22, 2023
  3. Junio C HamanoMar 22, 2023
  4. Clement MabileauMar 22, 2023
  5. Junio C HamanoMar 22, 2023
  6. 1/2 branch: improve error log on branch not found by checking remotes refsctmbl via GitGitGadget, Mar 22, 2023
  7. branch: improve error log on branch not found by checking remotes refsClementMabileau via GitGitGadget, Mar 22, 2023
  8. Junio C HamanoMar 22, 2023
  9. Clement MabileauMar 23, 2023
  10. Clement MabileauApr 4, 2023
  11. Junio C HamanoApr 4, 2023
  12. Clement MabileauApr 5, 2023
  13. branch: improve error log on branch not found by checking remotes refsClementMabileau via GitGitGadget, Apr 5, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.