Re: [PATCH v3 17/26] submodule--helper: fix obscure leak in module_add()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 21, 2022, 21:45 UTC
- Message-ID
- <xmqqlesmdtsk.fsf@gitster.g>
- In-Reply-To
- <patch-v3-17.26-7811bdbf149-20220721T191249Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Fix an obscure leak in module_add()< if the "git add" command we were
"<" -> "," perhaps? I dunno.
Show 14 quoted lines
> piping to failed we'd fail to strbuf_release(&sb). This fixes a leak > introduced in a6226fd772b (submodule--helper: convert the bulk of > cmd_add() to C, 2021-08-10). > > In fixing it move to a "goto cleanup" pattern, and since we need to > introduce a "ret" variable to do that let's also get rid of the > intermediate "exit_code" variable. The initialization to "-1" in > a6226fd772b has always been redundant, we'd only use the "exit_code" > value after assigning the return value of pipe_command() to it. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> > --- > builtin/submodule--helper.c | 22 +++++++++++----------- > 1 file changed, 11 insertions(+), 11 deletions(-)
The patch looks good, especially with removal of "exit_code" it is very clear what is going on and how errors are handled.
Nicely done.