diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index 09e184f0..34599e89 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -506,7 +506,9 @@ void FLAC::File::scan() return; } - if(blockLength == 0 && blockType != MetadataBlock::Padding) { + if(blockLength == 0 + && blockType != MetadataBlock::Padding && blockType != MetadataBlock::SeekTable) + { debug("FLAC::File::scan() -- Zero-sized metadata block found"); setValid(false); return; diff --git a/tests/data/empty-seektable.flac b/tests/data/empty-seektable.flac new file mode 100644 index 00000000..20dd90d9 Binary files /dev/null and b/tests/data/empty-seektable.flac differ diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index f2065e09..5bae7d88 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -63,6 +63,7 @@ class TestFLAC : public CppUnit::TestFixture CPPUNIT_TEST(testEmptyID3v2); CPPUNIT_TEST(testStripTags); CPPUNIT_TEST(testRemoveXiphField); + CPPUNIT_TEST(testEmptySeekTable); CPPUNIT_TEST_SUITE_END(); public: @@ -516,6 +517,24 @@ public: } } + void testEmptySeekTable() + { + ScopedFileCopy copy("empty-seektable", ".flac"); + { + FLAC::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(f.isValid()); + f.xiphComment(true)->setTitle("XiphComment Title"); + f.save(); + } + { + FLAC::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(f.isValid()); + f.seek(42); + const ByteVector data = f.readBlock(4); + CPPUNIT_ASSERT_EQUAL(ByteVector("\x03\x00\x00\x00", 4), data); + } + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestFLAC);