From 7c4b3648cad7faf990397af0b8a81664658c2d4f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 4 Nov 2022 08:56:42 +0100 Subject: [PATCH] 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 --- src/gui/image/qimage.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c4bd15d95b..f1029e786d 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -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());