Plug a few leaks in the tests · nodegit/libgit2@ae32c54 · GitHub
Skip to content

Commit ae32c54

Browse files
committed
Plug a few leaks in the tests
1 parent a07b169 commit ae32c54

6 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎src/refdb_fs.c‎

Lines changed: 4 additions & 1 deletion

‎src/reset.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ int git_reset(
167167
git_object_free(commit);
168168
git_index_free(index);
169169
git_tree_free(tree);
170+
git_buf_free(&log_message_buf);
170171

171172
return error;
172173
}

‎tests/clone/empty.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
5353
cl_git_pass(git_branch_upstream_name(&buf, g_repo_cloned, local_name));
5454

5555
cl_assert_equal_s(expected_tracked_branch_name, buf.ptr);
56+
git_buf_free(&buf);
5657

5758
/* ...and the name of the remote... */
5859
cl_git_pass(git_branch_remote_name(&buf, g_repo_cloned, expected_tracked_branch_name));
5960

6061
cl_assert_equal_s(expected_remote_name, buf.ptr);
62+
git_buf_free(&buf);
6163

6264
/* ...even when the remote HEAD is unborn as well */
6365
cl_assert_equal_i(GIT_ENOTFOUND, git_reference_lookup(&ref, g_repo_cloned,

‎tests/odb/backend/nobackend.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ void test_odb_backend_nobackend__initialize(void)
1818
git_repository_set_config(_repo, config);
1919
git_repository_set_odb(_repo, odb);
2020
git_repository_set_refdb(_repo, refdb);
21+
22+
/* The set increases the refcount and we don't want them anymore */
23+
git_config_free(config);
24+
git_odb_free(odb);
25+
git_refdb_free(refdb);
2126
}
2227

2328
void test_odb_backend_nobackend__cleanup(void)

‎tests/reset/hard.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,16 @@ void test_reset_hard__reflog_is_correct(void)
212212
reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
213213
reflog_check(repo, "refs/heads/master", 3, "emeric.fermas@gmail.com", exp_msg);
214214

215+
git_object_free(target);
216+
215217
/* Moved branch, expect default message */
216218
cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
217219
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, NULL));
218220
reflog_check(repo, "HEAD", 3, "emeric.fermas@gmail.com", exp_msg);
219221
reflog_check(repo, "refs/heads/master", 4, NULL, "reset: moving");
220222

223+
git_object_free(target);
224+
221225
/* Moved branch, expect custom message */
222226
cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
223227
cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL, "message1"));

‎tests/reset/mixed.c‎

Lines changed: 6 additions & 0 deletions

0 commit comments

Comments
 (0)