TestId3v2FrameFactory: Fix memory leak

The frames in a frameList() copy were not deleted because it had the
autoDelete property active. However, removed frames cannot be auto
deleted. Using setAutoDelete() affects the source of the copy, which has
to be investigated further.
This commit is contained in:
Urs Fleisch 2023-12-01 07:49:11 +01:00
parent bd06012b02
commit 3f11e0ae2f

View File

@ -131,9 +131,9 @@ public:
auto f = std::unique_ptr<File>(createFileWithDefaultFactory(fileName));
CPPUNIT_ASSERT(f->isValid());
ID3v2::Tag *tag = getID3v2Tag(*f);
const ID3v2::FrameList frames = tag->frameList();
for(const auto &frame : frames) {
tag->removeFrame(frame, false);
ID3v2::FrameList frames = tag->frameList();
for(auto it = frames.begin(); it != frames.end(); it = frames.erase(it)) {
tag->removeFrame(*it);
}
tag->setArtist("An artist");
tag->setTitle("A title");