diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-27 21:26:27 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-06-27 21:26:27 +0200 |
| commit | fa399750c680aa254784a40193d73d373df5e3ea (patch) | |
| tree | 323c8a96c3228c8be291d028b50c3483fda07395 /tests | |
| parent | 92ec9ed328c4864e9c3fc27d0894b40060eb74e5 (diff) | |
| parent | 24fa21f38e15b0c929cafb0c072e47708f18d663 (diff) | |
| download | libgit2-fa399750c680aa254784a40193d73d373df5e3ea.tar.gz | |
Merge pull request #3265 from libgit2/leaks
Plug a bunch of leaks
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/checkout/crlf.c | 20 | ||||
| -rw-r--r-- | tests/diff/binary.c | 6 | ||||
| -rw-r--r-- | tests/fetchhead/nonetwork.c | 3 | ||||
| -rw-r--r-- | tests/index/racy.c | 5 |
4 files changed, 27 insertions, 7 deletions
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c index 2cf3af364..8e77d0845 100644 --- a/tests/checkout/crlf.c +++ b/tests/checkout/crlf.c @@ -47,15 +47,19 @@ static int compare_file(void *payload, git_buf *actual_path) git_buf expected_contents = GIT_BUF_INIT; struct compare_data *cd = payload; bool failed = true; + int cmp_git, cmp_gitattributes; + char *basename; - if (strcmp(git_path_basename(actual_path->ptr), ".git") == 0 || - strcmp(git_path_basename(actual_path->ptr), ".gitattributes") == 0) { + basename = git_path_basename(actual_path->ptr); + cmp_git = strcmp(basename, ".git"); + cmp_gitattributes = strcmp(basename, ".gitattributes"); + + if (cmp_git == 0 || cmp_gitattributes == 0) { failed = false; goto done; } - cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, - git_path_basename(actual_path->ptr))); + cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, basename)); if (!git_path_isfile(expected_path.ptr) || !git_path_isfile(actual_path->ptr)) @@ -83,6 +87,7 @@ done: git_buf_free(&details); } + git__free(basename); git_buf_free(&expected_contents); git_buf_free(&actual_contents); git_buf_free(&expected_path); @@ -151,7 +156,12 @@ static void empty_workdir(const char *name) git_path_dirload(&contents, name, 0, 0); git_vector_foreach(&contents, i, fn) { - if (strncasecmp(git_path_basename(fn), ".git", 4) == 0) + char *basename = git_path_basename(fn); + int cmp = strncasecmp(basename, ".git", 4); + + git__free(basename); + + if (cmp == 0) continue; p_unlink(fn); } diff --git a/tests/diff/binary.c b/tests/diff/binary.c index 2d532637c..5298e9ebb 100644 --- a/tests/diff/binary.c +++ b/tests/diff/binary.c @@ -4,6 +4,7 @@ #include "buffer.h" #include "filebuf.h" +#include "repository.h" static git_repository *repo; @@ -496,7 +497,7 @@ void test_diff_binary__blob_to_blob(void) opts.id_abbrev = GIT_OID_HEXSZ; repo = cl_git_sandbox_init("renames"); - cl_git_pass(git_repository_index(&index, repo)); + cl_git_pass(git_repository_index__weakptr(&index, repo)); cl_git_append2file("renames/untimely.txt", "Oh that crazy Kipling!\r\n"); cl_git_pass(git_index_add_bypath(index, "untimely.txt")); @@ -531,4 +532,7 @@ void test_diff_binary__blob_to_blob(void) git__free(diff_data.old_path); git__free(diff_data.new_path); + + git_buf_free(&diff_data.old_binary_base85); + git_buf_free(&diff_data.new_binary_base85); } diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c index b8f74d7b6..3b750af5e 100644 --- a/tests/fetchhead/nonetwork.c +++ b/tests/fetchhead/nonetwork.c @@ -394,4 +394,7 @@ void test_fetchhead_nonetwork__create_when_refpecs_given(void) cl_git_pass(git_repository_fetchhead_foreach(g_repo, find_master, NULL)); cl_assert(find_master_called); cl_assert(found_master); + + git_remote_free(remote); + git_buf_free(&path); } diff --git a/tests/index/racy.c b/tests/index/racy.c index 3a4bc439e..fda1ed239 100644 --- a/tests/index/racy.c +++ b/tests/index/racy.c @@ -108,7 +108,7 @@ void test_index_racy__empty_file_after_smudge(void) const git_index_entry *entry; /* Make sure we do have a timestamp */ - cl_git_pass(git_repository_index(&index, g_repo)); + cl_git_pass(git_repository_index__weakptr(&index, g_repo)); cl_git_pass(git_index_write(index)); cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "A")); @@ -140,4 +140,7 @@ void test_index_racy__empty_file_after_smudge(void) cl_git_pass(git_diff_index_to_workdir(&diff, g_repo, index, NULL)); cl_assert_equal_i(1, git_diff_num_deltas(diff)); + + git_buf_free(&path); + git_diff_free(diff); } |
