checkout: plug a few 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
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 2cf3af3..8e77d08 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -47,15 +47,19 @@ static int compare_file(void *payload, git_buf *actual_path)
git_buf expected_contents = GIT_BUF_INIT;
struct compare_data *cd = payload;
bool failed = true;
+ int cmp_git, cmp_gitattributes;
+ char *basename;
- if (strcmp(git_path_basename(actual_path->ptr), ".git") == 0 ||
- strcmp(git_path_basename(actual_path->ptr), ".gitattributes") == 0) {
+ basename = git_path_basename(actual_path->ptr);
+ cmp_git = strcmp(basename, ".git");
+ cmp_gitattributes = strcmp(basename, ".gitattributes");
+
+ if (cmp_git == 0 || cmp_gitattributes == 0) {
failed = false;
goto done;
}
- cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname,
- git_path_basename(actual_path->ptr)));
+ cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, basename));
if (!git_path_isfile(expected_path.ptr) ||
!git_path_isfile(actual_path->ptr))
@@ -83,6 +87,7 @@ done:
git_buf_free(&details);
}
+ git__free(basename);
git_buf_free(&expected_contents);
git_buf_free(&actual_contents);
git_buf_free(&expected_path);
@@ -151,7 +156,12 @@ static void empty_workdir(const char *name)
git_path_dirload(&contents, name, 0, 0);
git_vector_foreach(&contents, i, fn) {
- if (strncasecmp(git_path_basename(fn), ".git", 4) == 0)
+ char *basename = git_path_basename(fn);
+ int cmp = strncasecmp(basename, ".git", 4);
+
+ git__free(basename);
+
+ if (cmp == 0)
continue;
p_unlink(fn);
}