Commit 4e83605
submodule--helper: fix obscure leak in module_add()
Fix an obscure leak in module_add(), if the "git add" command we were
piping to failed we'd fail to strbuf_release(&sb). This fixes a leak
introduced in a6226fd (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
a6226fd 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 <[email protected]>
Reviewed-by: Glen Choo <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>1 parent 4c81ee9 commit 4e83605
1 file changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3293 | 3293 | | |
3294 | 3294 | | |
3295 | 3295 | | |
| 3296 | + | |
| 3297 | + | |
3296 | 3298 | | |
3297 | 3299 | | |
3298 | 3300 | | |
| |||
3342 | 3344 | | |
3343 | 3345 | | |
3344 | 3346 | | |
3345 | | - | |
3346 | | - | |
3347 | 3347 | | |
3348 | 3348 | | |
3349 | 3349 | | |
3350 | 3350 | | |
3351 | 3351 | | |
3352 | 3352 | | |
3353 | | - | |
| 3353 | + | |
3354 | 3354 | | |
3355 | 3355 | | |
3356 | | - | |
3357 | | - | |
| 3356 | + | |
3358 | 3357 | | |
3359 | | - | |
3360 | 3358 | | |
3361 | 3359 | | |
3362 | 3360 | | |
| |||
3371 | 3369 | | |
3372 | 3370 | | |
3373 | 3371 | | |
3374 | | - | |
3375 | | - | |
3376 | | - | |
3377 | | - | |
| 3372 | + | |
| 3373 | + | |
3378 | 3374 | | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
3379 | 3378 | | |
3380 | 3379 | | |
| 3380 | + | |
3381 | 3381 | | |
3382 | | - | |
| 3382 | + | |
3383 | 3383 | | |
3384 | 3384 | | |
3385 | 3385 | | |
| |||
0 commit comments