From c2e1ccd968fc665742f436408089482b350853e8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 15 Aug 2006 00:04:34 +0000 Subject: tag.c: fix segfault on failed id3v1 character conversion convStrDup() returns NULL if character conversion fails, so make sure we check the return values and drop the tag if we can't get a conversion. This should close bug 1313: http://musicpd.org/mantis/view.php?id=1313 git-svn-id: https://svn.musicpd.org/mpd/trunk@4641 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/tag.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tag.c b/src/tag.c index c01293b2c..c3bb807e7 100644 --- a/src/tag.c +++ b/src/tag.c @@ -27,6 +27,7 @@ #include "charConv.h" #include "tagTracker.h" #include "mpd_types.h" +#include "gcc.h" #include #include @@ -168,8 +169,17 @@ MpdTag *getID3Info(struct id3_tag *tag, char *id, int type, MpdTag * mpdTag) setCharSetConversion("ISO-8859-1", "UTF-8"); isostr = convStrDup((char *)utf8); free(utf8); + if (mpd_unlikely(!isostr)) + continue; setCharSetConversion("UTF-8", encoding); utf8 = (id3_utf8_t *)convStrDup(isostr); + if (!utf8) { + DEBUG("Unable to convert %s string to " + "UTF-8: '%s'\n", + encoding, isostr); + free(isostr); + continue; + } free(isostr); } } -- cgit v1.2.3