diff --git a/gui/picturepreviewselection.cpp b/gui/picturepreviewselection.cpp index 409d163..890cf5a 100644 --- a/gui/picturepreviewselection.cpp +++ b/gui/picturepreviewselection.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -42,6 +43,7 @@ #include #include +#include #include #include @@ -269,8 +271,13 @@ template void pushId3v2CoverValues(TagType *tag, KnownField fiel pair->second.setValue(TagValue()); } } else if (!values[index].isEmpty()) { - typename TagType::FieldType field(id, values[index]); - field.setTypeInfo(index); + using FieldType = typename TagType::FieldType; + using TypeInfoType = typename FieldType::TypeInfoType; + using IndexCompareType = typename Traits::Conditional, make_unsigned::type, TypeInfoType>; + FieldType field(id, values[index]); + if (static_cast(index) < numeric_limits::max()) { + field.setTypeInfo(static_cast(index)); + } fields.insert(std::make_pair(id, field)); } } @@ -472,7 +479,7 @@ void PicturePreviewSelection::extractSelected() QMessageBox::warning(this, QCoreApplication::applicationName(), tr("Unable to open output file.")); return; } - if (file.write(value.dataPointer(), value.dataSize()) > 0) { + if (value.dataSize() <= numeric_limits::max() && file.write(value.dataPointer(), static_cast(value.dataSize())) > 0) { QMessageBox::information(this, QCoreApplication::applicationName(), tr("The cover has extracted.")); } else { QMessageBox::warning(this, QCoreApplication::applicationName(), tr("Unable to write to output file.")); @@ -504,8 +511,8 @@ void PicturePreviewSelection::displaySelected() tr("The attached image can't be found. It is supposed to be stored as external file \"%1\".").arg(fileName)); return; } - } else { - img = QImage::fromData(reinterpret_cast(value.dataPointer()), value.dataSize()); + } else if (value.dataSize() < numeric_limits::max()) { + img = QImage::fromData(reinterpret_cast(value.dataPointer()), static_cast(value.dataSize())); } if (img.isNull()) { QMessageBox::warning(this, QCoreApplication::applicationName(), tr("The attached image can't be displayed.")); @@ -709,8 +716,8 @@ void PicturePreviewSelection::updatePreview(int index) m_pixmapItem->setVisible(false); return; } - } else { - img = QImage::fromData(reinterpret_cast(value.dataPointer()), value.dataSize()); + } else if (value.dataSize() < numeric_limits::max()) { + img = QImage::fromData(reinterpret_cast(value.dataPointer()), static_cast(value.dataSize())); updateSizeAndMimeType(value.dataSize(), img.size(), QString::fromStdString(value.mimeType())); } if (img.isNull()) {