Handle allocation failure in QImage rotate 90/180/270 functions

Fixes: QTBUG-108186
Pick-to: 6.4 6.2 5.15
Change-Id: I354e75d9f063cdea0340b84e9585a61651a7c70f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Eirik Aavitsland 2022-11-04 08:56:42 +01:00
parent 124d682739
commit 7c4b3648ca

View File

@ -4674,6 +4674,8 @@ QImage QImage::smoothScaled(int w, int h) const
static QImage rotated90(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
if (out.isNull())
return out;
copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
@ -4702,6 +4704,8 @@ static QImage rotated180(const QImage &image)
return image.mirrored(true, true);
QImage out(image.width(), image.height(), image.format());
if (out.isNull())
return out;
copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());
@ -4714,6 +4718,8 @@ static QImage rotated180(const QImage &image)
static QImage rotated270(const QImage &image)
{
QImage out(image.height(), image.width(), image.format());
if (out.isNull())
return out;
copyMetadata(&out, image);
if (image.colorCount() > 0)
out.setColorTable(image.colorTable());