]> git.ipfire.org Git - thirdparty/git.git/commit - sequencer.c
sequencer: add a "goto cleanup" to do_reset()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 13 Oct 2021 13:23:54 +0000 (15:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 Oct 2021 17:37:11 +0000 (10:37 -0700)
commit0c52cf8e00f65bb198800a08caaadc95eaf4419a
tree8f6958b84159e4a4c650a116dd7301456559b6f5
parente5a917fcf42d2e22017ae501ffdd1c2108a1431e
sequencer: add a "goto cleanup" to do_reset()

Restructure code that's mostly added in 9055e401dd6 (sequencer:
introduce new commands to reset the revision, 2018-04-25) to avoid
code duplication, and to make freeing other resources easier in a
subsequent commit.

It's safe to initialize "tree_desc" to be zero'd out in order to
unconditionally free desc.buffer, it won't be initialized on the first
couple of "goto"'s.

There are three earlier "return"'s in this function which should
probably be made to use this new "cleanup" too, per [1] it looks like
they're leaving behind stale locks. But let's not try to fix every
potential bug here now, I'm just trying to narrowly plug a memory
leak.

1. https://lore.kernel.org/git/CABPp-BH=3DP-dXRCphY53-3eZd1TU8h5GY_M12nnbEGm-UYB9Q@mail.gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c