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

[PATCH v2 06/12] hook: plug a new memory leak

From
Junio C Hamano <gitster@pobox.com>
Date
May 24, 2024, 19:47 UTC
Message-ID
<20240524194715.695916-7-gitster@pobox.com>
In-Reply-To
<20240524194715.695916-1-gitster@pobox.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 8db1e8743c0 (clone: prevent hooks from running during a clone, 2024-03-28), I introduced an inadvertent memory leak that was unfortunately not caught before v2.45.1 was released. Here is a fix.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 hook.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hook.c b/hook.c
index 632b537b99..fc974cee1d 100644
--- a/hook.c
+++ b/hook.c
@@ -18,8 +18,10 @@ static int identical_to_template_hook(const char *name, const char *path)
 		found_template_hook = access(template_path.buf, X_OK) >= 0;
 	}
 #endif
-	if (!found_template_hook)
+	if (!found_template_hook) {
+		strbuf_release(&template_path);
 		return 0;
+	}
 
 	ret = do_files_match(template_path.buf, path);
 
-- 
2.45.1-246-gb9cfe4845c
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 13 in “Fix various overly aggressive protections in 2.45.1 and friends”
  1. 00/12 Fix various overly aggressive protections in 2.45.1 and friendsJunio C Hamano, May 24, 2024
  2. 01/12 send-email: drop FakeTerm hackJunio C Hamano, May 24, 2024
  3. 02/12 send-email: avoid creating more than one Term::ReadLine objectJunio C Hamano, May 24, 2024
  4. 03/12 ci: drop mention of BREW_INSTALL_PACKAGES variableJunio C Hamano, May 24, 2024
  5. 04/12 ci: avoid bare "gcc" for osx-gcc jobJunio C Hamano, May 24, 2024
  6. 05/12 ci: stop installing "gcc-13" for osx-gccJunio C Hamano, May 24, 2024
  7. 06/12 hook: plug a new memory leakJunio C Hamano, May 24, 2024
  8. 07/12 init: use the correct path of the templates directory againJunio C Hamano, May 24, 2024
  9. 08/12 Revert "core.hooksPath: add some protection while cloning"Junio C Hamano, May 24, 2024
  10. 09/12 tests: verify that `clone -c core.hooksPath=/dev/null` works againJunio C Hamano, May 24, 2024
  11. 10/12 clone: drop the protections where hooks aren't runJunio C Hamano, May 24, 2024
  12. 11/12 Revert "Add a helper function to compare file contents"Junio C Hamano, May 24, 2024
  13. 12/12 Revert "fsck: warn about symlink pointing inside a gitdir"Junio C Hamano, May 24, 2024

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.