79ca0ff4b5a5 — Chris Cannam 6 months ago
Prevent Ogg reader from silently returning broken reader when faced with non-Ogg data
1 files changed, 6 insertions(+), 1 deletions(-)

M src/OggVorbisReadStream.cpp
M src/OggVorbisReadStream.cpp +6 -1
@@ 190,7 190,7 @@
      FishSoundInfo fsinfo;
     m_d->m_fishSound = fish_sound_new(FISH_SOUND_DECODE, &fsinfo);
-
+    
     fish_sound_set_decoded_callback(m_d->m_fishSound, D::acceptFramesStatic, m_d);
     oggz_set_read_callback
         (m_d->m_oggz, -1, (OggzReadPacket)D::acceptPacketStatic, m_d);

          
@@ 199,6 199,11 @@
 while (m_channelCount == 0 && !m_d->m_finished) {
         m_d->readNextBlock(); 
     }
+
+    if (m_channelCount == 0) {
+	m_error = string("File \"") + m_path + "\" is not a valid Ogg Vorbis file.";
+        throw InvalidFileFormat(m_path, m_error);
+    }
 }
 
 OggVorbisReadStream::~OggVorbisReadStream()