From: Junio C Hamano Date: Thu, 21 Jul 2022 21:45:15 GMT Subject: Re: [PATCH v3 17/26] submodule--helper: fix obscure leak in module_add() Message-ID: In-Reply-To: Ævar Arnfjörð Bjarmason writes: > Fix an obscure leak in module_add()< if the "git add" command we were "<" -> "," perhaps? I dunno. > 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 > --- > 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.