From 0003ec68e9925a8386eb055e0030fe7f270aa56f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 20 Apr 2021 08:41:53 +0200 Subject: Use checked image allocation in image reader Utilize imageIO's common QImage creation function that implements QImageReader's allocation limit that was introduced in Qt 6. Pick-to: 6.1 Change-Id: Ie273bd874d18aeba30fd6b37d91aa72bd3725cd0 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/imageformats/svg/qsvgiohandler.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index 4136aaf..3e338b3 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -181,14 +181,11 @@ bool QSvgIOHandler::read(QImage *image) t.translate(tr1.x(), tr1.y()); bounds = t.mapRect(bounds); } - if (image->size() != finalSize || !image->reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)) { - *image = QImage(finalSize, QImage::Format_ARGB32_Premultiplied); - if (!finalSize.isEmpty() && image->isNull()) { - qWarning("QSvgIOHandler: QImage allocation failed (size %i x %i)", finalSize.width(), finalSize.height()); + if (finalSize.isEmpty()) { + *image = QImage(); + } else { + if (!QImageIOHandler::allocateImage(finalSize, QImage::Format_ARGB32_Premultiplied, image)) return false; - } - } - if (!finalSize.isEmpty()) { image->fill(d->backColor.rgba()); QPainter p(image); d->r.render(&p, bounds); -- cgit v1.2.1