]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: always free "struct replay_opts"
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 18 Apr 2024 13:14:05 +0000 (14:14 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Apr 2024 20:33:41 +0000 (13:33 -0700)
sequencer_post_commit_cleanup() initializes an instance of "struct
replay_opts" but does not call replay_opts_release(). Currently this
does not leak memory because the code paths called don't allocate any of
the struct members. That will change in the next commit so add call to
replay_opts_release() to prevent a memory leak in "git commit" that
breaks all of the leak free tests.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index f49a871ac0666b10393331ed3c9b611921f1039e..e4146b4cdfac496d170fc741873726bc86aa610e 100644 (file)
@@ -2823,12 +2823,14 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose)
                        NULL, REF_NO_DEREF);
 
        if (!need_cleanup)
-               return;
+               goto out;
 
        if (!have_finished_the_last_pick())
-               return;
+               goto out;
 
        sequencer_remove_state(&opts);
+out:
+       replay_opts_release(&opts);
 }
 
 static void todo_list_write_total_nr(struct todo_list *todo_list)