Commit 585094cc4638fafe1884bb6f4c2fa291e8111222

Carlos Martín Nieto 2015-03-25T02:22:42

Merge pull request #3017 from ethomson/leaks squash some leaks

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);
 }