Commit 37ce381
committed
worktree: fix resource leaks when branch creation fails
In the "add" subcommand, when run_command() fails while creating
a new branch (line 948), the function returns -1 immediately
without freeing the allocations made earlier: path (from
prefix_filename at line 858), opt_track, branch_to_free, and
new_branch_to_free.
Redirect the error return through the existing cleanup block at
the end of the function so all four allocations are properly
freed.
Pointed out by Coverity.
Assisted-by: Claude Opus 4.6
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 58f4661 commit 37ce381
1 file changed
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
949 | | - | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
950 | 952 | | |
951 | 953 | | |
952 | 954 | | |
953 | 955 | | |
954 | 956 | | |
955 | 957 | | |
| 958 | + | |
956 | 959 | | |
957 | 960 | | |
958 | 961 | | |
| |||
0 commit comments