fix overflows in the max image size code (#2950)

* fix overflows in the max image size code

* Update Image.cpp
This commit is contained in:
fourtf 2021-07-03 22:11:10 +02:00 committed by GitHub
parent 6830e8b01b
commit 804bc526b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -406,9 +406,10 @@ void Image::actuallyLoad()
buffer.open(QIODevice::ReadOnly);
QImageReader reader(&buffer);
if (reader.size().width() * reader.size().height() *
reader.imageCount() * 4 >
Image::maxBytesRam)
// use "double" to prevent int overflows
if (double(reader.size().width()) * double(reader.size().height()) *
double(reader.imageCount()) * 4.0 >
double(Image::maxBytesRam))
{
qCDebug(chatterinoImage) << "image too large in RAM";