diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-05-01 18:56:55 +0100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2017-05-01 18:56:55 +0100 |
commit | be343b88c724491bcb945cafec9f95370eb1088f (patch) | |
tree | 123c68b8c8ea1a78fe12dab983c35597c4055a89 /src/branch.c | |
parent | 13c1bf0718363960c1867f35c9ce3ebc7bf74729 (diff) | |
download | libgit2-be343b88c724491bcb945cafec9f95370eb1088f.tar.gz |
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`.
Diffstat (limited to 'src/branch.c')
-rw-r--r-- | src/branch.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/branch.c b/src/branch.c index 7a83b83af..fe4955ad6 100644 --- a/src/branch.c +++ b/src/branch.c @@ -130,14 +130,16 @@ int git_branch_create_from_annotated( static int branch_equals(git_repository *repo, const char *path, void *payload) { git_reference *branch = (git_reference *) payload; - git_reference *head; - int equal; + git_reference *head = NULL; + int equal = 0; if (git_reference__read_head(&head, repo, path) < 0 || - git_reference_type(head) != GIT_REF_SYMBOLIC) - return 0; + git_reference_type(head) != GIT_REF_SYMBOLIC) + goto done; equal = !git__strcmp(head->target.symbolic, branch->name); + +done: git_reference_free(head); return equal; } |