Merge pull request #4636 from tiennou/fix/leaks Fix leaks in master
diff --git a/src/refspec.c b/src/refspec.c
index 01a77c9..943a9c7 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -304,6 +304,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
git_buf buf = GIT_BUF_INIT;
size_t j, pos;
git_remote_head key;
+ git_refspec *cur;
const char* formatters[] = {
GIT_REFS_DIR "%s",
@@ -312,7 +313,9 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
NULL
};
- git_refspec *cur = git__calloc(1, sizeof(git_refspec));
+ assert(out && spec && refs);
+
+ cur = git__calloc(1, sizeof(git_refspec));
GITERR_CHECK_ALLOC(cur);
cur->force = spec->force;
diff --git a/tests/worktree/worktree.c b/tests/worktree/worktree.c
index 9b932d8..c79d97f 100644
--- a/tests/worktree/worktree.c
+++ b/tests/worktree/worktree.c
@@ -300,6 +300,7 @@ void test_worktree_worktree__add_with_explicit_branch(void)
git_reference_free(branch);
git_reference_free(wthead);
git_repository_free(wtrepo);
+ git_worktree_free(wt);
}