diff -Nurw id3v2-0.1.11/id3v2.cpp id3v2-0.1.11-works/id3v2.cpp --- id3v2-0.1.11/id3v2.cpp 2004-05-04 19:30:15.000000000 +0100 +++ id3v2-0.1.11-works/id3v2.cpp 2008-11-03 11:30:58.000000000 +0000 @@ -423,7 +423,7 @@ { // check if there is a total track number and if we only have // the track number for this file. In this case combine them. - char *currentTrackNum, *newTrackNum; + char *currentTrackNum, *newTrackNum=NULL; if (pFrame != NULL) { @@ -444,7 +444,7 @@ myFrame->Field(ID3FN_TEXT) = frameList[ii].data; myTag.AttachFrame(myFrame); - free(newTrackNum); + if ( newTrackNum ) free(newTrackNum); break; } case ID3FID_USERTEXT: @@ -599,7 +599,7 @@ } case ID3FID_PICTURE: { - char +/* char *sMimeType = ID3_GetString(myFrame, ID3FN_MIMETYPE), *sDesc = ID3_GetString(myFrame, ID3FN_DESCRIPTION), *sFormat = ID3_GetString(myFrame, ID3FN_IMAGEFORMAT); @@ -612,6 +612,33 @@ delete [] sMimeType; delete [] sDesc; delete [] sFormat; +*/ + char MIMEtype[16]; + ID3_Frame thisFrame; + if ( strlen(frameList[ii].data) ) { + char *fnextension = strrchr(frameList[ii].data,'.'); + if ( ! fnextension ) { + std::cout << "APIC frame: could not determine MIME type of attached picture" << std::endl; + exit(1); + } + fnextension++; + strcpy(MIMEtype,"image/"); + if ( !strcasecmp(fnextension,"jpg") || !strcasecmp(fnextension,"jpeg") ) strcat(MIMEtype,"jpeg"); + else if ( !strcasecmp(fnextension,"gif") ) strcat(MIMEtype,"gif"); + else if ( !strcasecmp(fnextension,"png") ) strcat(MIMEtype,"png"); + else if ( !strcasecmp(fnextension,"bmp") ) strcat(MIMEtype,"bmp"); + if ( strlen(MIMEtype) == 6 ) { + std::cout << "APIC frame: could not determine MIME type of attached picture" << std::endl; + exit(1); + } + thisFrame.SetID(ID3FID_PICTURE); + thisFrame.GetField(ID3FN_MIMETYPE)->Set(MIMEtype); + thisFrame.GetField(ID3FN_PICTURETYPE)->Set(3); /* We're assuming it's the cover art */ + thisFrame.GetField(ID3FN_DESCRIPTION)->Set("Album cover"); + thisFrame.GetField(ID3FN_DATA)->FromFile(frameList[ii].data); + } + if ( pFrame ) myTag.RemoveFrame(pFrame); + if ( strlen(frameList[ii].data) ) myTag.AddFrame(thisFrame); break; } case ID3FID_GENERALOBJECT: