Merge pull request #3017 from ethomson/leaks squash some leaks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/src/refs.c b/src/refs.c
index 360e653..ff5e240 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1052,12 +1052,10 @@ static int get_terminal(git_reference **out, git_repository *repo, const char *r
error = 0;
} else {
error = get_terminal(out, repo, git_reference_symbolic_target(ref), nesting + 1);
- if (error == GIT_ENOTFOUND) {
- if (!*out) /* set by the error case in lookup above */
- *out = ref;
- } else {
+ if (error == GIT_ENOTFOUND && !*out)
+ *out = ref;
+ else
git_reference_free(ref);
- }
}
return error;
diff --git a/src/repository.c b/src/repository.c
index 6a80070..7cffc9f 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -133,7 +133,9 @@ void git_repository_free(git_repository *repo)
for (i = 0; i < repo->reserved_names.size; i++)
git_buf_free(git_array_get(repo->reserved_names, i));
+ git_array_clear(repo->reserved_names);
+ git__free(repo->path_gitlink);
git__free(repo->path_repository);
git__free(repo->workdir);
git__free(repo->namespace);
diff --git a/tests/filter/file.c b/tests/filter/file.c
index 865c416..8243a02 100644
--- a/tests/filter/file.c
+++ b/tests/filter/file.c
@@ -64,6 +64,7 @@ int buf_writestream_write(git_writestream *s, const char *buf, size_t len)
int buf_writestream_close(git_writestream *s)
{
+ GIT_UNUSED(s);
return 0;
}
@@ -94,4 +95,5 @@ void test_filter_file__apply_stream(void)
cl_assert_equal_s("crlf\ncrlf\ncrlf\ncrlf\n", write_target.buf.ptr);
git_filter_list_free(fl);
+ write_target.base.free((struct git_writestream *)&write_target);
}