summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-03-22 20:26:01 +0200
committerVicent Marti <tanoku@gmail.com>2011-03-22 20:38:36 +0200
commit21d73e7195a427b39c1c3742c85254e8384f5802 (patch)
tree86cec2f6051fc4f9f5d42e4598bfa594d360e7e7
parent1881f0783b6dd23fb40ba0b43a4ec98bb08a637c (diff)
downloadlibgit2-21d73e7195a427b39c1c3742c85254e8384f5802.tar.gz
Always free the parents of a revwalk commit
Thanks to Carlos Martín Nieto for spotting this.
-rw-r--r--src/revwalk.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index a9d4f8734..73bb060f5 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -482,11 +482,22 @@ int git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo)
void git_revwalk_free(git_revwalk *walk)
{
unsigned int i;
+ const void *_unused;
+ commit_object *commit;
if (walk == NULL)
return;
git_revwalk_reset(walk);
+
+ /* if the parent has more than PARENTS_PER_COMMIT parents,
+ * we had to allocate a separate array for those parents.
+ * make sure it's being free'd */
+ GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, {
+ if (commit->out_degree > PARENTS_PER_COMMIT)
+ free(commit->parents);
+ });
+
git_hashtable_free(walk->commits);
git_pqueue_free(&walk->iterator_time);