mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 20:02:04 +00:00
worktrees: cleanup some memory leaks
Be sure to clean up looked up references. Free buffers instead of merely clearing them. Use `git__free` instead of `free`.
This commit is contained in:
parent
13c1bf0718
commit
be343b88c7
@ -130,14 +130,16 @@ int git_branch_create_from_annotated(
|
|||||||
static int branch_equals(git_repository *repo, const char *path, void *payload)
|
static int branch_equals(git_repository *repo, const char *path, void *payload)
|
||||||
{
|
{
|
||||||
git_reference *branch = (git_reference *) payload;
|
git_reference *branch = (git_reference *) payload;
|
||||||
git_reference *head;
|
git_reference *head = NULL;
|
||||||
int equal;
|
int equal = 0;
|
||||||
|
|
||||||
if (git_reference__read_head(&head, repo, path) < 0 ||
|
if (git_reference__read_head(&head, repo, path) < 0 ||
|
||||||
git_reference_type(head) != GIT_REF_SYMBOLIC)
|
git_reference_type(head) != GIT_REF_SYMBOLIC)
|
||||||
return 0;
|
goto done;
|
||||||
|
|
||||||
equal = !git__strcmp(head->target.symbolic, branch->name);
|
equal = !git__strcmp(head->target.symbolic, branch->name);
|
||||||
|
|
||||||
|
done:
|
||||||
git_reference_free(head);
|
git_reference_free(head);
|
||||||
return equal;
|
return equal;
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ int git_reference__read_head(
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free(name);
|
git__free(name);
|
||||||
git_buf_clear(&reference);
|
git_buf_free(&reference);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -2132,7 +2132,8 @@ int git_repository_head_for_worktree(git_reference **out, git_repository *repo,
|
|||||||
out:
|
out:
|
||||||
if (error)
|
if (error)
|
||||||
git_reference_free(head);
|
git_reference_free(head);
|
||||||
git_buf_clear(&path);
|
|
||||||
|
git_buf_free(&path);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user