diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-10-12 04:48:31 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-10-12 05:27:34 -0700 |
commit | c7fb996848715ee43f5df238aff75e561a4451b9 (patch) | |
tree | 965e566a9a528e842a01a7b41970f33ed0f8deca /src/directory.c | |
parent | bb106c3bf8daf366a4b4ca7229010c038f89755c (diff) | |
download | mpd-c7fb996848715ee43f5df238aff75e561a4451b9.tar.gz mpd-c7fb996848715ee43f5df238aff75e561a4451b9.tar.xz mpd-c7fb996848715ee43f5df238aff75e561a4451b9.zip |
directory: children leave parents before being free()ed
This prevents double-free()s when doing teardown of
a directory.
Diffstat (limited to '')
-rw-r--r-- | src/directory.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) |