From c6dbba6c5dc37ecb79195bb515beeffdb0e380a6 Mon Sep 17 00:00:00 2001 From: "J. Alexander Treuman" Date: Wed, 21 Jun 2006 16:11:07 +0000 Subject: Cleanup mp3_parseId3Tag to only modify the MpdTag if we have something new to replace it with. git-svn-id: https://svn.musicpd.org/mpd/trunk@4278 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/inputPlugins/mp3_plugin.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 79215bcd9..30d1cfe02 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -260,8 +260,7 @@ static void mp3_parseId3Tag(mp3DecodeData * data, signed long tagsize, MpdTag ** id3_length_t count; id3_byte_t const *id3_data; id3_byte_t * allocated = NULL; - - if(mpdTag) *mpdTag = NULL; + MpdTag * newMpdTag; count = data->stream.bufend - data->stream.this_frame; @@ -298,13 +297,18 @@ static void mp3_parseId3Tag(mp3DecodeData * data, signed long tagsize, MpdTag ** } id3Tag = id3_tag_parse(id3_data, tagsize); - - if(id3Tag) { - if(mpdTag) *mpdTag = parseId3Tag(id3Tag); - if(replayGainInfo) mp3_getReplayGainInfo(id3Tag, replayGainInfo); - id3_tag_delete(id3Tag); + if(!id3Tag) goto fail; + + if(mpdTag) { + newMpdTag = parseId3Tag(id3Tag); + if(newMpdTag) { + if(*mpdTag) freeMpdTag(*mpdTag); + *mpdTag = newMpdTag; + } } + if(replayGainInfo) mp3_getReplayGainInfo(id3Tag, replayGainInfo); + id3_tag_delete(id3Tag); fail: if(allocated) free(allocated); } -- cgit v1.2.3