]> granicus.if.org Git - taglib/commitdiff
Discard empty ID3v2 frames instead of adding a dummy null byte.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 24 Mar 2015 01:31:52 +0000 (10:31 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 24 Mar 2015 01:31:52 +0000 (10:31 +0900)
taglib/mpeg/id3v2/id3v2frame.cpp
taglib/mpeg/id3v2/id3v2tag.cpp

index 85e9f66da1e9be6abed5aa664e6f097174417ffb..bee5375adfc90b8dceed9419944e02c3deb5f433 100644 (file)
@@ -193,9 +193,6 @@ void Frame::setText(const String &)
 ByteVector Frame::render() const
 {
   ByteVector fieldData = renderFields();
-  if(fieldData.isEmpty())
-    fieldData = ByteVector("\x00", 1);
-
   d->header->setFrameSize(fieldData.size());
   ByteVector headerData = d->header->render();
 
index 267a45d04e1b27da78b9f5e0fdf3c46a63c6c14c..33345407a953ce10a1ce6d478b394af8c78d6d2c 100644 (file)
@@ -591,12 +591,19 @@ ByteVector ID3v2::Tag::render(int version) const
   for(FrameList::ConstIterator it = frameList.begin(); it != frameList.end(); it++) {
     (*it)->header()->setVersion(version);
     if((*it)->header()->frameID().size() != 4) {
-      debug("A frame of unsupported or unknown type \'"
+      debug("An ID3v2 frame of unsupported or unknown type \'"
           + String((*it)->header()->frameID()) + "\' has been discarded");
       continue;
     }
-    if(!(*it)->header()->tagAlterPreservation())
+    if(!(*it)->header()->tagAlterPreservation()) {
+      const ByteVector frameData = (*it)->render();
+      if(frameData.size() == Frame::headerSize()) {
+        debug("An empty ID3v2 frame \'"
+          + String((*it)->header()->frameID()) + "\' has been discarded");
+        continue;
+      }
       tagData.append((*it)->render());
+    }
   }
 
   // Compute the amount of padding, and append that to tagData.