diff options
author | Max Kellermann <max@duempel.org> | 2009-08-14 11:52:00 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-08-14 11:52:00 +0200 |
commit | 7dddd9beda2bb0505758bb6a32cae6feb3215733 (patch) | |
tree | f3ec694012345f3e255c05c88771bee824aa3d3c | |
parent | 5d6f7803e1059f527a70e541ed3945c19bd78c90 (diff) | |
download | mpd-7dddd9beda2bb0505758bb6a32cae6feb3215733.tar.gz mpd-7dddd9beda2bb0505758bb6a32cae6feb3215733.tar.xz mpd-7dddd9beda2bb0505758bb6a32cae6feb3215733.zip |
directory: free empty directories after removing them (memleak)
dirvec_delete() does not free the object, we have to call
directory_free() afterwards.
Diffstat (limited to '')
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/directory.c | 11 |
2 files changed, 9 insertions, 3 deletions
@@ -8,6 +8,7 @@ ver 0.15.2 (2009/??/??) - flac: don't allocate cuesheet twice (memleak) * update: free empty path string (memleak) * update: free temporary string in container scan (memleak) +* directory: free empty directories after removing them (memleak) ver 0.15.1 (2009/07/15) 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); |