Commit 89886d0b by Carlos Martín Nieto

Plug a bunch of leaks

parent a5123ea8
......@@ -87,6 +87,8 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
static int is_index_extended(git_index *index);
static int write_index(git_index *index, git_filebuf *file);
static void index_entry_free(git_index_entry *entry);
static int index_srch(const void *key, const void *array_member)
{
const git_index_entry *entry = array_member;
......@@ -157,8 +159,17 @@ int git_index_open(git_index **index_out, const char *index_path)
static void index_free(git_index *index)
{
git_index_entry *e;
unsigned int i;
git_index_clear(index);
git_vector_foreach(&index->entries, i, e) {
index_entry_free(e);
}
git_vector_free(&index->entries);
git_vector_foreach(&index->unmerged, i, e) {
index_entry_free(e);
}
git_vector_free(&index->unmerged);
git__free(index->index_file_path);
......
......@@ -154,6 +154,7 @@ static int retrieve_head_tree(git_tree **tree_out, git_repository *repo)
if ((error = git_commit_lookup(&head_commit, repo, git_reference_oid(resolved_head_ref))) < GIT_SUCCESS)
return git__rethrow(error, "The tip of HEAD can't be retrieved");
git_reference_free(resolved_head_ref);
if ((error = git_commit_tree(&tree, head_commit)) < GIT_SUCCESS) {
error = git__rethrow(error, "The tree of HEAD can't be retrieved");
goto exit;
......
......@@ -37,6 +37,7 @@ void test_repo_getters__head_detached(void)
git_oid_fromstr(&oid, "c47800c7266a2be04c571c04d5a6614691ea99bd");
cl_git_pass(git_reference_create_oid(&ref, repo, "HEAD", &oid, 1));
cl_assert(git_repository_head_detached(repo) == 1);
git_reference_free(ref);
/* take the reop back to it's original state */
cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
......@@ -58,6 +59,7 @@ void test_repo_getters__head_orphan(void)
/* orphan HEAD */
cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/orphan", 1));
cl_assert(git_repository_head_orphan(repo) == 1);
git_reference_free(ref);
/* take the reop back to it's original state */
cl_git_pass(git_reference_create_symbolic(&ref, repo, "HEAD", "refs/heads/master", 1));
......
......@@ -759,6 +759,7 @@ BEGIN_TEST(root0, "create a root commit")
must_be_true(!strcmp(git_commit_message(commit), ROOT_COMMIT_MESSAGE));
/* Remove the data we just added to the repo */
git_reference_free(head);
must_pass(git_reference_lookup(&head, repo, "HEAD"));
must_pass(git_reference_set_target(head, head_old));
must_pass(git_reference_delete(branch));
......
......@@ -243,6 +243,7 @@ BEGIN_TEST(write3, "Replace an already existing tag")
must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b"));
git_oid_cpy(&old_tag_id, git_reference_oid(ref_tag));
git_reference_free(ref_tag);
/* create signature */
must_pass(git_signature_new(&tagger, TAGGER_NAME, TAGGER_EMAIL, 123456789, 60));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment