mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
Check AIFF/WAV files for duplicate tags.
AIFF/WAV files can have duplicate tags and it leads to memory leak.
This commit is contained in:
BIN
tests/data/duplicate_id3v2.aiff
Normal file
BIN
tests/data/duplicate_id3v2.aiff
Normal file
Binary file not shown.
BIN
tests/data/duplicate_tags.wav
Normal file
BIN
tests/data/duplicate_tags.wav
Normal file
Binary file not shown.
@ -15,6 +15,7 @@ class TestAIFF : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testReading);
|
||||
CPPUNIT_TEST(testSaveID3v2);
|
||||
CPPUNIT_TEST(testAiffCProperties);
|
||||
CPPUNIT_TEST(testDuplicateID3v2);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
@ -50,8 +51,19 @@ public:
|
||||
{
|
||||
RIFF::AIFF::File f(TEST_FILE_PATH_C("alaw.aifc"));
|
||||
CPPUNIT_ASSERT(f.audioProperties()->isAiffC());
|
||||
CPPUNIT_ASSERT(f.audioProperties()->compressionType() == "ALAW");
|
||||
CPPUNIT_ASSERT(f.audioProperties()->compressionName() == "SGI CCITT G.711 A-law");
|
||||
CPPUNIT_ASSERT_EQUAL(ByteVector("ALAW"), f.audioProperties()->compressionType());
|
||||
CPPUNIT_ASSERT_EQUAL(String("SGI CCITT G.711 A-law"), f.audioProperties()->compressionName());
|
||||
}
|
||||
|
||||
void testDuplicateID3v2()
|
||||
{
|
||||
RIFF::AIFF::File f(TEST_FILE_PATH_C("duplicate_id3v2.aiff"));
|
||||
|
||||
// duplicate_id3v2.aiff has duplicate ID3v2 tags.
|
||||
// title() returns "Title2" if can't skip the second tag.
|
||||
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Title1"), f.tag()->title());
|
||||
}
|
||||
|
||||
void testFuzzedFile1()
|
||||
|
@ -96,14 +96,12 @@ public:
|
||||
|
||||
void testDuplicateID3v2()
|
||||
{
|
||||
ScopedFileCopy copy("duplicate_id3v2", ".mp3");
|
||||
string newname = copy.fileName();
|
||||
|
||||
MPEG::File f(newname.c_str());
|
||||
MPEG::File f(TEST_FILE_PATH_C("duplicate_id3v2.mp3"));
|
||||
|
||||
// duplicate_id3v2.mp3 has duplicate ID3v2 tags.
|
||||
// Sample rate will be 32000 if can't skip the second tag.
|
||||
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ class TestWAV : public CppUnit::TestFixture
|
||||
CPPUNIT_TEST(testID3v2Tag);
|
||||
CPPUNIT_TEST(testInfoTag);
|
||||
CPPUNIT_TEST(testStripTags);
|
||||
CPPUNIT_TEST(testDuplicateTags);
|
||||
CPPUNIT_TEST(testFuzzedFile1);
|
||||
CPPUNIT_TEST(testFuzzedFile2);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
@ -141,6 +142,20 @@ public:
|
||||
delete f;
|
||||
}
|
||||
|
||||
void testDuplicateTags()
|
||||
{
|
||||
RIFF::WAV::File f(TEST_FILE_PATH_C("duplicate_tags.wav"));
|
||||
|
||||
// duplicate_tags.wav has duplicate ID3v2/INFO tags.
|
||||
// title() returns "Title2" if can't skip the second tag.
|
||||
|
||||
CPPUNIT_ASSERT(f.hasID3v2Tag());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Title1"), f.ID3v2Tag()->title());
|
||||
|
||||
CPPUNIT_ASSERT(f.hasInfoTag());
|
||||
CPPUNIT_ASSERT_EQUAL(String("Title1"), f.InfoTag()->title());
|
||||
}
|
||||
|
||||
void testFuzzedFile1()
|
||||
{
|
||||
RIFF::WAV::File f1(TEST_FILE_PATH_C("infloop.wav"));
|
||||
|
Reference in New Issue
Block a user