Verify type of ID3v2 frames used for complex properties (#1173)

A frame with ID "APIC" is not guaranteed to be an AttachedPictureFrame,
it can also be an invalid UnknownFrame with ID "APIC". Check the types
of the frames before accessing them.
This commit is contained in:
Urs Fleisch 2023-11-09 20:59:47 +01:00
parent 0e395f4ec4
commit 9679b08120

View File

@ -472,26 +472,28 @@ List<VariantMap> ID3v2::Tag::complexProperties(const String &key) const
if(uppercaseKey == "PICTURE") {
const FrameList pictures = d->frameListMap.value("APIC");
for(const Frame *frame : pictures) {
auto picture = static_cast<const AttachedPictureFrame *>(frame);
VariantMap property;
property.insert("data", picture->picture());
property.insert("mimeType", picture->mimeType());
property.insert("description", picture->description());
property.insert("pictureType",
AttachedPictureFrame::typeToString(picture->type()));
properties.append(property);
if(auto picture = dynamic_cast<const AttachedPictureFrame *>(frame)) {
VariantMap property;
property.insert("data", picture->picture());
property.insert("mimeType", picture->mimeType());
property.insert("description", picture->description());
property.insert("pictureType",
AttachedPictureFrame::typeToString(picture->type()));
properties.append(property);
}
}
}
else if(uppercaseKey == "GENERALOBJECT") {
const FrameList geobs = d->frameListMap.value("GEOB");
for(const Frame *frame : geobs) {
auto geob = static_cast<const GeneralEncapsulatedObjectFrame *>(frame);
VariantMap property;
property.insert("data", geob->object());
property.insert("mimeType", geob->mimeType());
property.insert("description", geob->description());
property.insert("fileName", geob->fileName());
properties.append(property);
if(auto geob = dynamic_cast<const GeneralEncapsulatedObjectFrame *>(frame)) {
VariantMap property;
property.insert("data", geob->object());
property.insert("mimeType", geob->mimeType());
property.insert("description", geob->description());
property.insert("fileName", geob->fileName());
properties.append(property);
}
}
}
return properties;