Merge pull request #1540 from ethomson/leaks fix 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
diff --git a/src/diff.c b/src/diff.c
index a154e67..fbff1a6 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -716,7 +716,7 @@ static int diff_scan_inside_untracked_dir(
error = git_iterator_advance(&info->nitem, info->new_iter);
}
- return error;
+ goto done;
}
/* look for actual untracked file */
@@ -747,6 +747,7 @@ static int diff_scan_inside_untracked_dir(
break;
}
+done:
git_buf_free(&base);
return error;
diff --git a/src/index.c b/src/index.c
index d4aa475..ee659f8 100644
--- a/src/index.c
+++ b/src/index.c
@@ -349,6 +349,7 @@ static void index_free(git_index *index)
{
git_index_clear(index);
git_vector_free(&index->entries);
+ git_vector_free(&index->names);
git_vector_free(&index->reuc);
git__free(index->index_file_path);
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index a5ad1e4..765b914 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -23,10 +23,16 @@ int git_smart__store_refs(transport_smart *t, int flushes)
int error, flush = 0, recvd;
const char *line_end;
git_pkt *pkt;
+ git_pkt_ref *ref;
+ size_t i;
/* Clear existing refs in case git_remote_connect() is called again
* after git_remote_disconnect().
*/
+ git_vector_foreach(refs, i, ref) {
+ git__free(ref->head.name);
+ git__free(ref);
+ }
git_vector_clear(refs);
do {
diff --git a/tests-clar/commit/parse.c b/tests-clar/commit/parse.c
index 8de4401..415860a 100644
--- a/tests-clar/commit/parse.c
+++ b/tests-clar/commit/parse.c
@@ -386,10 +386,6 @@ This commit has a few LF at the start of the commit message";
\n\
This commit has a few LF at the start of the commit message";
- commit = (git_commit*)git__malloc(sizeof(git_commit));
- memset(commit, 0x0, sizeof(git_commit));
- commit->object.repo = g_repo;
-
cl_git_pass(parse_commit(&commit, buffer));
cl_assert_equal_s(message, git_commit_message(commit));
git_commit__free(commit);
diff --git a/tests-clar/submodule/status.c b/tests-clar/submodule/status.c
index fca84af..88f3880 100644
--- a/tests-clar/submodule/status.c
+++ b/tests-clar/submodule/status.c
@@ -409,4 +409,6 @@ void test_submodule_status__untracked_dirs_containing_ignored_files(void)
GIT_SUBMODULE_STATUS_IN_WD;
cl_assert(status == expected);
+
+ git_buf_free(&path);
}