From c7fb996848715ee43f5df238aff75e561a4451b9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 12 Oct 2008 04:48:31 -0700 Subject: directory: children leave parents before being free()ed This prevents double-free()s when doing teardown of a directory. --- src/directory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/directory.c b/src/directory.c index 3ebac6830..40be57855 100644 --- a/src/directory.c +++ b/src/directory.c @@ -60,8 +60,11 @@ void directory_free(struct directory *dir) directory_walk(dir, free_each_song, free_each_dir, dir); dirvec_destroy(&dir->children); songvec_destroy(&dir->songs); - if (dir != &music_root) + if (dir != &music_root) { + assert(dir->parent); + dirvec_delete(&dir->parent->children, dir); free(dir); + } } static int dir_pruner(struct directory *dir, void *_dv) -- cgit v1.2.3