Commit afd8a94e by Carlos Martín Nieto

checkout: plug a few leaks

parent 9568660f
...@@ -47,15 +47,19 @@ static int compare_file(void *payload, git_buf *actual_path) ...@@ -47,15 +47,19 @@ static int compare_file(void *payload, git_buf *actual_path)
git_buf expected_contents = GIT_BUF_INIT; git_buf expected_contents = GIT_BUF_INIT;
struct compare_data *cd = payload; struct compare_data *cd = payload;
bool failed = true; bool failed = true;
int cmp_git, cmp_gitattributes;
char *basename;
if (strcmp(git_path_basename(actual_path->ptr), ".git") == 0 || basename = git_path_basename(actual_path->ptr);
strcmp(git_path_basename(actual_path->ptr), ".gitattributes") == 0) { cmp_git = strcmp(basename, ".git");
cmp_gitattributes = strcmp(basename, ".gitattributes");
if (cmp_git == 0 || cmp_gitattributes == 0) {
failed = false; failed = false;
goto done; goto done;
} }
cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, cl_git_pass(git_buf_joinpath(&expected_path, cd->dirname, basename));
git_path_basename(actual_path->ptr)));
if (!git_path_isfile(expected_path.ptr) || if (!git_path_isfile(expected_path.ptr) ||
!git_path_isfile(actual_path->ptr)) !git_path_isfile(actual_path->ptr))
...@@ -83,6 +87,7 @@ done: ...@@ -83,6 +87,7 @@ done:
git_buf_free(&details); git_buf_free(&details);
} }
git__free(basename);
git_buf_free(&expected_contents); git_buf_free(&expected_contents);
git_buf_free(&actual_contents); git_buf_free(&actual_contents);
git_buf_free(&expected_path); git_buf_free(&expected_path);
...@@ -151,7 +156,12 @@ static void empty_workdir(const char *name) ...@@ -151,7 +156,12 @@ static void empty_workdir(const char *name)
git_path_dirload(&contents, name, 0, 0); git_path_dirload(&contents, name, 0, 0);
git_vector_foreach(&contents, i, fn) { 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; continue;
p_unlink(fn); p_unlink(fn);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment