psd: Don't abort on broken images

oss-fuzz/46418
This commit is contained in:
Albert Astals Cid
2022-04-06 00:35:02 +02:00
parent 84d56d00cf
commit 5c47a97b79
3 changed files with 22 additions and 4 deletions

View File

@ -28,6 +28,8 @@
#include "psd_p.h"
#include "util_p.h"
#include <QDataStream>
#include <QDebug>
#include <QImage>
@ -636,6 +638,12 @@ static bool LoadPSD(QDataStream &stream, const PSDHeader &header, QImage &img)
auto imgChannels = imageChannels(img.format());
auto channel_num = std::min(qint32(header.channel_count), imgChannels);
auto raw_count = qsizetype(header.width * header.depth + 7) / 8;
if (header.height > kMaxQVectorSize / header.channel_count / sizeof(quint32)) {
qWarning() << "LoadPSD() header height/channel_count too big" << header.height << header.channel_count;
return false;
}
QVector<quint32> strides(header.height * header.channel_count, raw_count);
// Read the compressed stride sizes
if (compression)