]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hook: plug a new memory leak
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 20 May 2024 20:22:00 +0000 (20:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 21 May 2024 19:33:08 +0000 (12:33 -0700)
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

diff --git a/hook.c b/hook.c
index 632b537b9933ad4f4011a3b3b316a1de5b99de21..fc974cee1d842fd3f01f0f37b3480ed0104049b0 100644 (file)
--- 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);