From 2c908fde1b5f0c0be1c7c7d4dd4fd444c31ae341 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 15:09:22 +0200 Subject: [PATCH 1/5] output_thread: check again if output is open on CANCEL When the player thread unpauses, it sends CANCEL to the output thread, after having checked that the output is still open. Problem is when the output thread closes the device before it can process the CANCEL command - race condition. This patch adds another "open" check inside the output thread. --- NEWS | 1 + src/output_thread.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ec6cbe663..af70f783b 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ ver 0.15.5 (2009/??/??) * tags: - riff, aiff: fixed "limited range" gcc warning * decoder_thread: change the fallback decoder name to "mad" +* output_thread: check again if output is open on CANCEL ver 0.15.4 (2009/10/03) diff --git a/src/output_thread.c b/src/output_thread.c index 785ac808f..9ca844623 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -257,7 +257,8 @@ static gpointer audio_output_task(gpointer arg) case AO_COMMAND_CANCEL: ao->chunk = NULL; - ao_plugin_cancel(ao->plugin, ao->data); + if (ao->open) + ao_plugin_cancel(ao->plugin, ao->data); ao_command_finished(ao); /* the player thread will now clear our music From d1ba27d820dc96c41cc3814801c12392060692dc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:37:54 +0200 Subject: [PATCH 2/5] update: song_file_new() cannot fail Removed the NULL check. If that NULL check was correct, that would have been a memory leak (vtrack). --- src/update.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/update.c b/src/update.c index 593198cb9..4aa48f25c 100644 --- a/src/update.c +++ b/src/update.c @@ -459,8 +459,6 @@ update_container_file( struct directory* directory, while ((vtrack = plugin->container_scan(pathname, ++tnum)) != NULL) { struct song* song = song_file_new(vtrack, contdir); - if (song == NULL) - return true; // shouldn't be necessary but it's there.. song->mtime = st->st_mtime; @@ -468,7 +466,6 @@ update_container_file( struct directory* directory, song->tag = plugin->tag_dup(map_directory_child_fs(contdir, vtrack)); songvec_add(&contdir->songs, song); - song = NULL; modified = true; From 8ae5bc4d790d026a25049dd213814429ff8c8b2b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:38:15 +0200 Subject: [PATCH 3/5] update: fixed memory leak during container scan The return value of map_directory_child_fs() must be freed. --- NEWS | 1 + src/update.c | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index af70f783b..54e0e8cc9 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ ver 0.15.5 (2009/??/??) - riff, aiff: fixed "limited range" gcc warning * decoder_thread: change the fallback decoder name to "mad" * output_thread: check again if output is open on CANCEL +* update: fixed memory leak during container scan ver 0.15.4 (2009/10/03) diff --git a/src/update.c b/src/update.c index 4aa48f25c..24960b449 100644 --- a/src/update.c +++ b/src/update.c @@ -459,17 +459,20 @@ update_container_file( struct directory* directory, while ((vtrack = plugin->container_scan(pathname, ++tnum)) != NULL) { struct song* song = song_file_new(vtrack, contdir); + char *child_path_fs; // shouldn't be necessary but it's there.. song->mtime = st->st_mtime; - song->tag = plugin->tag_dup(map_directory_child_fs(contdir, vtrack)); + child_path_fs = map_directory_child_fs(contdir, vtrack); + g_free(vtrack); + + song->tag = plugin->tag_dup(child_path_fs); + g_free(child_path_fs); songvec_add(&contdir->songs, song); modified = true; - - g_free(vtrack); } g_free(pathname); From d09e19c3dc6216ff0b3b4a69a778e45482ae66c5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:39:17 +0200 Subject: [PATCH 4/5] decoder/flac: fixed two memory leaks in the CUE tag loader Don't initialize "vc" and "cs" with FLAC__metadata_object_new(); that value is overwritten by FLAC__metadata_get_tags() and FLAC__metadata_get_cuesheet(). --- NEWS | 2 ++ src/decoder/flac_plugin.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 54e0e8cc9..2a8316866 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ ver 0.15.5 (2009/??/??) - curl: fixed endless loop during buffering * tags: - riff, aiff: fixed "limited range" gcc warning +* decoders: + - flac: fixed two memory leaks in the CUE tag loader * decoder_thread: change the fallback decoder name to "mad" * output_thread: check again if output is open on CANCEL * update: fixed memory leak during container scan diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 1d7a9f868..1d5d48d09 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -299,10 +299,10 @@ flac_cue_tag_load(const char *file) unsigned int sample_rate = 0; FLAC__uint64 track_time = 0; #ifdef HAVE_CUE /* libcue */ - FLAC__StreamMetadata* vc = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT); + FLAC__StreamMetadata* vc; #endif /* libcue */ FLAC__StreamMetadata* si = FLAC__metadata_object_new(FLAC__METADATA_TYPE_STREAMINFO); - FLAC__StreamMetadata* cs = FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET); + FLAC__StreamMetadata* cs; tnum = flac_vtrack_tnum(file); char_tnum = g_strdup_printf("%u", tnum); @@ -326,6 +326,7 @@ flac_cue_tag_load(const char *file) } } } + FLAC__metadata_object_delete(vc); } #endif /* libcue */ From 7df1a2c77d7f0ac2073d3fe9c7ff85dc4a28e12a Mon Sep 17 00:00:00 2001 From: Avuton Olrich Date: Sun, 18 Oct 2009 09:50:16 -0700 Subject: [PATCH 5/5] mpd version 0.15.5 --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2a8316866..564140b80 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -ver 0.15.5 (2009/??/??) +ver 0.15.5 (2009/10/18) * input: - curl: don't abort if a packet has only metadata - curl: fixed endless loop during buffering diff --git a/configure.ac b/configure.ac index d476a74a9..ad119139d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.15.5~git, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.15.5, musicpd-dev-team@lists.sourceforge.net) AC_CONFIG_SRCDIR([src/main.c]) AM_INIT_AUTOMAKE([foreign 1.9 dist-bzip2]) AM_CONFIG_HEADER(config.h)