410257d0237b — Chris Cannam 2 years ago
Now that readExpectedTag skips mismatched chunks, we don't want to use it for the WAVE tag, which is not a chunk
1 files changed, 8 insertions(+), 2 deletions(-)

M src/SimpleWavFileReadStream.cpp
M src/SimpleWavFileReadStream.cpp +8 -2
@@ 89,8 89,14 @@ SimpleWavFileReadStream::readHeader()
         throw std::logic_error("internal error: no file in readHeader");
     }
     
-    uint32_t totalSize = readExpectedChunkSize("RIFF");
-    readExpectedTag("WAVE");
+    (void) readExpectedChunkSize("RIFF");
+
+    string found = readTag();
+    if (found != "WAVE") {
+        throw InvalidFileFormat
+            (m_path, "RIFF file is not WAVE format");
+    }
+
     uint32_t fmtSize = readExpectedChunkSize("fmt ");
     if (fmtSize < 16) {
         cout << "fmtSize = " << fmtSize << endl;