Plug 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
diff --git a/src/submodule.c b/src/submodule.c
index 998ef91..3fd3388 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -229,6 +229,7 @@ int git_submodule_lookup(
if (error < 0) {
git_submodule_free(sm);
+ git_buf_free(&path);
return error;
}
@@ -1699,6 +1700,8 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg)
* should be strcasecmp
*/
if (strcmp(sm->name, value) != 0) {
+ if (sm->path != sm->name)
+ git__free(sm->path);
sm->path = git__strdup(value);
GITERR_CHECK_ALLOC(sm->path);
}
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index 5e6a060..96c9723 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -48,6 +48,8 @@ void test_core_mkdir__absolute(void)
cl_assert(!git_path_isdir(path.ptr));
cl_git_fail(git_futils_mkdir(path.ptr, 0755, 0));
cl_assert(!git_path_isdir(path.ptr));
+
+ git_buf_free(&path);
}
void test_core_mkdir__basic(void)
diff --git a/tests/index/rename.c b/tests/index/rename.c
index ebaa9b7..86eaf00 100644
--- a/tests/index/rename.c
+++ b/tests/index/rename.c
@@ -77,5 +77,10 @@ void test_index_rename__casechanging(void)
cl_assert_equal_i(1, git_index_entrycount(index));
else
cl_assert_equal_i(2, git_index_entrycount(index));
+
+ git_index_free(index);
+ git_repository_free(repo);
+
+ cl_fixture_cleanup("rename");
}