Add error message on unaligned profile inputs

Pick-to: 5.15
Task-number: QTBUG-84267
Change-Id: I7ec2100455bd0178cdff0de2d24abbe6c19f812f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
Allan Sandfeld Jensen 2020-05-18 15:19:06 +02:00
parent cdfafec01b
commit dddd0c3ad8
2 changed files with 8 additions and 0 deletions

View File

@ -666,6 +666,9 @@ QByteArray QColorSpace::iccProfile() const
If the ICC profile is not supported an invalid QColorSpace is returned
where you can still read the original ICC profile using iccProfile().
\note If the QByteArray data is created from external sources it should be
at least 4 byte aligned.
\sa iccProfile()
*/
QColorSpace QColorSpace::fromIccProfile(const QByteArray &iccProfile)

View File

@ -614,6 +614,11 @@ bool parseDesc(const QByteArray &data, const TagEntry &tagEntry, QString &descNa
bool fromIccProfile(const QByteArray &data, QColorSpace *colorSpace)
{
Q_ASSERT((reinterpret_cast<qintptr>(data.constData()) & 0x3) == 0);
if (reinterpret_cast<qintptr>(data.constData()) & 0x3) {
qCWarning(lcIcc) << "fromIccProfile: Unaligned profile data";
return false;
}
if (data.size() < qsizetype(sizeof(ICCProfileHeader))) {
qCWarning(lcIcc) << "fromIccProfile: failed size sanity 1";
return false;