Commit 1a8167af by Carlos Martín Nieto

status: don't hide tree closing

It's not obvious that recurse_tree_entries or recurse_tree_entry
should free a resource that wasn't allocated by them. Do this
explicitely and plug a leak while we're at it.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
parent cd0fe1ac
...@@ -90,6 +90,7 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path ...@@ -90,6 +90,7 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path
if (git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid) == GIT_SUCCESS) { if (git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid) == GIT_SUCCESS) {
recurse_tree_entries(subtree, entries, file_path); recurse_tree_entries(subtree, entries, file_path);
git_tree_close(subtree);
return; return;
} }
...@@ -100,8 +101,6 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path ...@@ -100,8 +101,6 @@ static void recurse_tree_entries(git_tree *tree, git_vector *entries, char *path
git_oid_cpy(&e->head_oid, &tree_entry->oid); git_oid_cpy(&e->head_oid, &tree_entry->oid);
} }
git_tree_close(tree);
} }
static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const char *path) static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const char *path)
...@@ -121,6 +120,7 @@ static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const cha ...@@ -121,6 +120,7 @@ static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const cha
if (tree_entry != NULL) { if (tree_entry != NULL) {
if (git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid) == GIT_SUCCESS) { if (git_tree_lookup(&subtree, tree->object.repo, &tree_entry->oid) == GIT_SUCCESS) {
recurse_tree_entry(subtree, e, dir_sep+1); recurse_tree_entry(subtree, e, dir_sep+1);
git_tree_close(subtree);
return; return;
} }
} }
...@@ -130,7 +130,6 @@ static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const cha ...@@ -130,7 +130,6 @@ static void recurse_tree_entry(git_tree *tree, struct status_entry *e, const cha
if (tree_entry != NULL) { if (tree_entry != NULL) {
git_oid_cpy(&e->head_oid, &tree_entry->oid); git_oid_cpy(&e->head_oid, &tree_entry->oid);
} }
git_tree_close(tree);
} }
struct status_st { struct status_st {
...@@ -277,6 +276,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig ...@@ -277,6 +276,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
// recurse through tree entries // recurse through tree entries
git_commit_tree(&tree, head_commit); git_commit_tree(&tree, head_commit);
recurse_tree_entries(tree, &entries, ""); recurse_tree_entries(tree, &entries, "");
git_tree_close(tree);
git_commit_close(head_commit); git_commit_close(head_commit);
dirent_st.workdir_path_len = strlen(repo->path_workdir); dirent_st.workdir_path_len = strlen(repo->path_workdir);
...@@ -342,6 +342,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char ...@@ -342,6 +342,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
git_commit_tree(&tree, head_commit); git_commit_tree(&tree, head_commit);
recurse_tree_entry(tree, e, path); recurse_tree_entry(tree, e, path);
git_tree_close(tree);
git_commit_close(head_commit); git_commit_close(head_commit);
// Find file in Workdir // Find file in Workdir
......
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