Re: [PATCH v3 12/25] split_commit_in_progress(): fix memory leak
- From
René Scharfe <l.s.r@web.de>
- Date
- May 3, 2017, 20:59 UTC
- Message-ID
- <8a0a2230-239e-b6c8-f7c0-8192e6cec7ec@web.de>
- In-Reply-To
- <8cc59c706934134294e91a99062f7dcc0bda17db.1493740497.git.johannes.schindelin@gmx.de>
Am 02.05.2017 um 18:02 schrieb Johannes Schindelin:
Show 27 quoted lines
> Reported via Coverity.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> wt-status.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/wt-status.c b/wt-status.c
> index 0a6e16dbe0f..1f3f6bcb980 100644
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1088,8 +1088,13 @@ static int split_commit_in_progress(struct wt_status *s)
> char *rebase_orig_head = read_line_from_git_path("rebase-merge/orig-head");
>
> if (!head || !orig_head || !rebase_amend || !rebase_orig_head ||
> - !s->branch || strcmp(s->branch, "HEAD"))
> + !s->branch || strcmp(s->branch, "HEAD")) {
> + free(head);
> + free(orig_head);
> + free(rebase_amend);
> + free(rebase_orig_head);
> return split_in_progress;
> + }
>
> if (!strcmp(rebase_amend, rebase_orig_head)) {
> if (strcmp(head, rebase_amend))
> The return line could be replaced by "; else" to achieve the same result, without duplicating the free calls.
René