diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2023-02-07 02:07:52 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-07 02:34:40 +0300 |
commit | 1fdd31cf52a242c3b73b4093a68a30123c5c7549 (patch) | |
tree | 63b04faafec25668a818e266e068833b117d54d1 /builtin/receive-pack.c | |
parent | fb2ebe72a37423e7c375d933d3c277b8cc81efba (diff) |
receive-pack: release the linked "struct command *" list
Fix a memory leak that's been with us since this code was introduced
in [1]. Later in [2] we started using FLEX_ALLOC_MEM() to allocate the
"struct command *".
1. 575f497456e (Add first cut at "git-receive-pack", 2005-06-29)
2. eb1af2df0b1 (git-receive-pack: start parsing ref update commands,
2005-06-29)
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r-- | builtin/receive-pack.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a90af30363..cd5c7a28ef 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2032,6 +2032,16 @@ static struct command **queue_command(struct command **tail, return &cmd->next; } +static void free_commands(struct command *commands) +{ + while (commands) { + struct command *next = commands->next; + + free(commands); + commands = next; + } +} + static void queue_commands_from_cert(struct command **tail, struct strbuf *push_cert) { @@ -2569,6 +2579,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix) run_receive_hook(commands, "post-receive", 1, &push_options); run_update_post_hook(commands); + free_commands(commands); string_list_clear(&push_options, 0); if (auto_gc) { struct child_process proc = CHILD_PROCESS_INIT; |