diff options
| author | Carlos MartÃn Nieto <carlosmn@github.com> | 2018-01-17 12:29:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-17 12:29:05 +0000 |
| commit | ecd55cec771d9c6f7ffffe80422a1decd4645c17 (patch) | |
| tree | c3891ea014d0027d11fb66f3e5f916d98652b1d5 | |
| parent | f1323d9c161aeeada190fd9615a8b5a9fb8a7f3e (diff) | |
| parent | 782402c271d5467f9890af8e808af938a93bc55f (diff) | |
| download | libgit2-ecd55cec771d9c6f7ffffe80422a1decd4645c17.tar.gz | |
Merge pull request #4477 from pks-t/pks/memleaks
Memory leaks
| -rw-r--r-- | include/git2/refs.h | 3 | ||||
| -rw-r--r-- | src/transports/local.c | 2 | ||||
| -rw-r--r-- | tests/network/fetchlocal.c | 8 | ||||
| -rw-r--r-- | tests/refs/iterator.c | 1 |
4 files changed, 6 insertions, 8 deletions
diff --git a/include/git2/refs.h b/include/git2/refs.h index dee28cb5b..0dd453e55 100644 --- a/include/git2/refs.h +++ b/include/git2/refs.h @@ -433,6 +433,9 @@ typedef int (*git_reference_foreach_name_cb)(const char *name, void *payload); * passed to this method. Returning a non-zero value from the callback * will terminate the iteration. * + * Note that the callback function is responsible to call `git_reference_free` + * on each reference passed to it. + * * @param repo Repository where to find the refs * @param callback Function which will be called for every listed ref * @param payload Additional data to pass to the callback diff --git a/src/transports/local.c b/src/transports/local.c index ae117db29..740cf36a9 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -519,6 +519,8 @@ static int foreach_reference_cb(git_reference *reference, void *payload) error = 0; } + git_reference_free(reference); + return error; } diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c index 17c8f26e3..91e2a0595 100644 --- a/tests/network/fetchlocal.c +++ b/tests/network/fetchlocal.c @@ -314,12 +314,6 @@ void test_network_fetchlocal__prune_tag(void) git_repository_free(repo); } -static void cleanup_sandbox(void *unused) -{ - GIT_UNUSED(unused); - cl_git_sandbox_cleanup(); -} - void test_network_fetchlocal__partial(void) { git_repository *repo = cl_git_sandbox_init("partial-testrepo"); @@ -332,7 +326,6 @@ void test_network_fetchlocal__partial(void) options.callbacks.transfer_progress = transfer_cb; options.callbacks.payload = &callcount; - cl_set_cleanup(&cleanup_sandbox, NULL); cl_git_pass(git_reference_list(&refnames, repo)); cl_assert_equal_i(1, (int)refnames.count); @@ -420,7 +413,6 @@ void test_network_fetchlocal__multi_remotes(void) git_strarray refnames = {0}; git_fetch_options options = GIT_FETCH_OPTIONS_INIT; - cl_set_cleanup(&cleanup_sandbox, NULL); options.callbacks.transfer_progress = transfer_cb; cl_git_pass(git_remote_set_url(repo, "test", cl_git_fixture_url("testrepo.git"))); cl_git_pass(git_remote_lookup(&test, repo, "test")); diff --git a/tests/refs/iterator.c b/tests/refs/iterator.c index 56f6ce505..18e9d1d5b 100644 --- a/tests/refs/iterator.c +++ b/tests/refs/iterator.c @@ -213,6 +213,7 @@ void test_refs_iterator__foreach_name(void) git_vector_foreach(&output, i, name) { cl_assert(refnames[i] != NULL); cl_assert_equal_s(refnames[i], name); + git__free(name); } git_vector_free(&output); |
