diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2021-03-19 11:09:28 +0100 |
---|---|---|
committer | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2021-03-19 16:47:49 +0100 |
commit | e08eaf2c10135b204ee64ebec26d702c729d8545 (patch) | |
tree | 4bd474e92f29781d0f2a5938e82f68285e68818e /src/gui/painting | |
parent | 8f2f70a8fffd67a60ecc0c319275ecec1d5db2bd (diff) |
paintengine: improve error handling
Just check for null image/oom initially, no need to do it for every
scanline.
Reported by static analysis.
Change-Id: I86c3f09556b99b889e720901a3691bb0f730ac02
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpaintengine_raster.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 26f8de5b8b..19a0fac972 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3745,6 +3745,8 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color) const QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB); QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied); + if (sourceImage.isNull() || dest.isNull()) + return image; // we must have run out of memory QRgb fg = qPremultiply(color.rgba()); QRgb bg = 0; @@ -3754,8 +3756,6 @@ QImage QRasterBuffer::colorizeBitmap(const QImage &image, const QColor &color) for (int y=0; y<height; ++y) { const uchar *source = sourceImage.constScanLine(y); QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y)); - if (!source || !target) - QT_THROW(std::bad_alloc()); // we must have run out of memory for (int x=0; x < width; ++x) target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg; } |