add a maximum RAM usage for images

This commit is contained in:
fourtf
2021-06-24 22:54:36 +02:00
parent 97b9bfb2bd
commit ed6ef0b98e
2 changed files with 13 additions and 0 deletions
+10
View File
@@ -405,6 +405,16 @@ void Image::actuallyLoad()
QBuffer buffer(const_cast<QByteArray *>(&data));
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer);
if (reader.size().width() * reader.size().height() *
reader.imageCount() * 4 >
Image::maxBytesRam)
{
qCDebug(chatterinoImage) << "image too large in RAM";
return Failure;
}
auto parsed = detail::readFrames(reader, shared->url());
postToThread(makeConvertCallback(parsed, [weak](auto frames) {