From 7dddd9beda2bb0505758bb6a32cae6feb3215733 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 14 Aug 2009 11:52:00 +0200 Subject: directory: free empty directories after removing them (memleak) dirvec_delete() does not free the object, we have to call directory_free() afterwards. --- src/directory.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/directory.c') diff --git a/src/directory.c b/src/directory.c index 85c24fd04..ef8c038a3 100644 --- a/src/directory.c +++ b/src/directory.c @@ -73,9 +73,14 @@ directory_prune_empty(struct directory *directory) struct dirvec *dv = &directory->children; for (i = dv->nr; --i >= 0; ) { - directory_prune_empty(dv->base[i]); - if (directory_is_empty(dv->base[i])) - dirvec_delete(dv, dv->base[i]); + struct directory *child = dv->base[i]; + + directory_prune_empty(child); + + if (directory_is_empty(child)) { + dirvec_delete(dv, child); + directory_free(child); + } } if (!dv->nr) dirvec_destroy(dv); -- cgit v1.2.3