From 2c908fde1b5f0c0be1c7c7d4dd4fd444c31ae341 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 15:09:22 +0200 Subject: 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. --- src/output_thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3 From d1ba27d820dc96c41cc3814801c12392060692dc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:37:54 +0200 Subject: 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(-) (limited to 'src') 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; -- cgit v1.2.3 From 8ae5bc4d790d026a25049dd213814429ff8c8b2b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:38:15 +0200 Subject: update: fixed memory leak during container scan The return value of map_directory_child_fs() must be freed. --- src/update.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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); -- cgit v1.2.3 From d09e19c3dc6216ff0b3b4a69a778e45482ae66c5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Oct 2009 17:39:17 +0200 Subject: 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(). --- src/decoder/flac_plugin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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 */ -- cgit v1.2.3