]> granicus.if.org Git - taglib/commitdiff
Skip duplicate chunks when reading AIFF/WAV files.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 24 May 2015 15:40:13 +0000 (00:40 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Sun, 24 May 2015 15:40:13 +0000 (00:40 +0900)
Similar to #492.
There is no good reason to use the last chunk rather than the first one.

taglib/riff/aiff/aifffile.cpp
taglib/riff/wav/wavfile.cpp

index 595b29509ada3960a34378b72aad4ba5ec53c0bc..c7cadb6712b406b83dd4914b10b8d06ab472bec6 100644 (file)
@@ -150,8 +150,14 @@ void RIFF::AIFF::File::read(bool readProperties, Properties::ReadStyle propertie
         debug("RIFF::AIFF::File::read() - Duplicate ID3v2 tag found.");
       }
     }
-    else if(name == "COMM" && readProperties)
-      formatData = chunkData(i);
+    else if(name == "COMM" && readProperties) {
+      if(formatData.isEmpty()) {
+        formatData = chunkData(i);
+      }
+      else {
+        debug("RIFF::AIFF::File::read() - Duplicate 'COMM' chunk found.");
+      }
+    }
   }
 
   if(!d->tag)
index 4b379fa4b34c5798f47799fd3ef8241d7735a328..aa367b5d953e50c12d335d392be1bf26028c4251 100644 (file)
@@ -217,10 +217,22 @@ void RIFF::WAV::File::read(bool readProperties, Properties::ReadStyle properties
         }
       }
     }
-    else if(name == "fmt " && readProperties)
-      formatData = chunkData(i);
-    else if(name == "data" && readProperties)
-      streamLength = chunkDataSize(i);
+    else if(name == "fmt " && readProperties) {
+      if(formatData.isEmpty()) {
+        formatData = chunkData(i);
+      }
+      else {
+        debug("RIFF::WAV::File::read() - Duplicate 'fmt ' chunk found.");
+      }
+    }
+    else if(name == "data" && readProperties) {
+      if(streamLength == 0) {
+        streamLength = chunkDataSize(i);
+      }
+      else {
+        debug("RIFF::WAV::File::read() - Duplicate 'data' chunk found.");
+      }
+    }
   }
 
   if(!d->tag[ID3v2Index])